From 70809b6a6e0035e2a02f403c5b32e61383ca0719 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Thu, 10 Aug 2023 18:31:06 +0200 Subject: [PATCH 01/51] virtuerl: init --- .gitignore | 2 +- virtuerl/.gitignore | 24 + virtuerl/.idea/.gitignore | 5 + virtuerl/.idea/codeStyles/Project.xml | 7 + virtuerl/.idea/codeStyles/codeStyleConfig.xml | 5 + virtuerl/.idea/compiler.xml | 6 + virtuerl/.idea/modules.xml | 20 + virtuerl/.idea/vcs.xml | 6 + virtuerl/LICENSE.md | 186 + virtuerl/README.md | 9 + virtuerl/Vagrantfile | 77 + virtuerl/bird.conf | 171 + virtuerl/config/sys.config | 15 + virtuerl/erlang_ls.config | 9 + virtuerl/rebar.config | 20 + virtuerl/rebar.lock | 56 + virtuerl/src/pb/controller_pb.erl | 8217 +++++++++++++++++ virtuerl/src/pb/controller_service_bhvr.erl | 157 + virtuerl/src/pb/controller_service_client.erl | 691 ++ virtuerl/src/pb/daemon_pb.erl | 5962 ++++++++++++ virtuerl/src/pb/daemon_service_bhvr.erl | 109 + virtuerl/src/pb/daemon_service_client.erl | 475 + virtuerl/src/pb/dns_bhvr.erl | 25 + virtuerl/src/pb/dns_client.erl | 97 + virtuerl/src/pb/dns_pb.erl | 1228 +++ virtuerl/src/pb/domain_pb.erl | 3401 +++++++ virtuerl/src/pb/domain_service_bhvr.erl | 45 + virtuerl/src/pb/domain_service_client.erl | 187 + virtuerl/src/pb/host_pb.erl | 1431 +++ virtuerl/src/pb/host_service_bhvr.erl | 33 + virtuerl/src/pb/host_service_client.erl | 133 + virtuerl/src/pb/port_forwarding_pb.erl | 1320 +++ .../src/pb/port_forwarding_service_bhvr.erl | 25 + .../src/pb/port_forwarding_service_client.erl | 97 + virtuerl/src/pb/route_pb.erl | 1912 ++++ virtuerl/src/pb/route_service_bhvr.erl | 45 + virtuerl/src/pb/route_service_client.erl | 187 + virtuerl/src/pb/volume_pb.erl | 2159 +++++ virtuerl/src/pb/volume_service_bhvr.erl | 45 + virtuerl/src/pb/volume_service_client.erl | 187 + virtuerl/src/virtuerl.app.src | 16 + virtuerl/src/virtuerl_api.erl | 163 + virtuerl/src/virtuerl_api_domain_col.erl | 58 + virtuerl/src/virtuerl_api_domain_res.erl | 58 + virtuerl/src/virtuerl_app.erl | 25 + virtuerl/src/virtuerl_ipam.erl | 202 + virtuerl/src/virtuerl_mgt.erl | 118 + virtuerl/src/virtuerl_net.erl | 220 + virtuerl/src/virtuerl_qemu.erl | 70 + virtuerl/src/virtuerl_sup.erl | 65 + virtuerl/test/ipam.erl | 83 + virtuerl/test/scheduler.erl | 6 + virtuerl/virtuerl.iml | 22 + 53 files changed, 29891 insertions(+), 1 deletion(-) create mode 100644 virtuerl/.gitignore create mode 100644 virtuerl/.idea/.gitignore create mode 100644 virtuerl/.idea/codeStyles/Project.xml create mode 100644 virtuerl/.idea/codeStyles/codeStyleConfig.xml create mode 100644 virtuerl/.idea/compiler.xml create mode 100644 virtuerl/.idea/modules.xml create mode 100644 virtuerl/.idea/vcs.xml create mode 100644 virtuerl/LICENSE.md create mode 100644 virtuerl/README.md create mode 100644 virtuerl/Vagrantfile create mode 100644 virtuerl/bird.conf create mode 100644 virtuerl/config/sys.config create mode 100644 virtuerl/erlang_ls.config create mode 100644 virtuerl/rebar.config create mode 100644 virtuerl/rebar.lock create mode 100644 virtuerl/src/pb/controller_pb.erl create mode 100644 virtuerl/src/pb/controller_service_bhvr.erl create mode 100644 virtuerl/src/pb/controller_service_client.erl create mode 100644 virtuerl/src/pb/daemon_pb.erl create mode 100644 virtuerl/src/pb/daemon_service_bhvr.erl create mode 100644 virtuerl/src/pb/daemon_service_client.erl create mode 100644 virtuerl/src/pb/dns_bhvr.erl create mode 100644 virtuerl/src/pb/dns_client.erl create mode 100644 virtuerl/src/pb/dns_pb.erl create mode 100644 virtuerl/src/pb/domain_pb.erl create mode 100644 virtuerl/src/pb/domain_service_bhvr.erl create mode 100644 virtuerl/src/pb/domain_service_client.erl create mode 100644 virtuerl/src/pb/host_pb.erl create mode 100644 virtuerl/src/pb/host_service_bhvr.erl create mode 100644 virtuerl/src/pb/host_service_client.erl create mode 100644 virtuerl/src/pb/port_forwarding_pb.erl create mode 100644 virtuerl/src/pb/port_forwarding_service_bhvr.erl create mode 100644 virtuerl/src/pb/port_forwarding_service_client.erl create mode 100644 virtuerl/src/pb/route_pb.erl create mode 100644 virtuerl/src/pb/route_service_bhvr.erl create mode 100644 virtuerl/src/pb/route_service_client.erl create mode 100644 virtuerl/src/pb/volume_pb.erl create mode 100644 virtuerl/src/pb/volume_service_bhvr.erl create mode 100644 virtuerl/src/pb/volume_service_client.erl create mode 100644 virtuerl/src/virtuerl.app.src create mode 100644 virtuerl/src/virtuerl_api.erl create mode 100644 virtuerl/src/virtuerl_api_domain_col.erl create mode 100644 virtuerl/src/virtuerl_api_domain_res.erl create mode 100644 virtuerl/src/virtuerl_app.erl create mode 100644 virtuerl/src/virtuerl_ipam.erl create mode 100644 virtuerl/src/virtuerl_mgt.erl create mode 100644 virtuerl/src/virtuerl_net.erl create mode 100644 virtuerl/src/virtuerl_qemu.erl create mode 100644 virtuerl/src/virtuerl_sup.erl create mode 100644 virtuerl/test/ipam.erl create mode 100644 virtuerl/test/scheduler.erl create mode 100644 virtuerl/virtuerl.iml diff --git a/.gitignore b/.gitignore index 6478b2e..5638fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.idea/ +#.idea/ venv/ .venv/ __pycache__/ diff --git a/virtuerl/.gitignore b/virtuerl/.gitignore new file mode 100644 index 0000000..210b641 --- /dev/null +++ b/virtuerl/.gitignore @@ -0,0 +1,24 @@ +.DS_Store +.vagrant/ +khepri*/ + +.rebar3 +_build +_checkouts +_vendor +.eunit +*.o +*.beam +*.plt +*.swp +*.swo +.erlang.cookie +ebin +log +erl_crash.dump +.rebar +logs +#.idea +#*.iml +rebar3.crashdump +*~ diff --git a/virtuerl/.idea/.gitignore b/virtuerl/.idea/.gitignore new file mode 100644 index 0000000..24de6c7 --- /dev/null +++ b/virtuerl/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +misc.xml +rebar.xml diff --git a/virtuerl/.idea/codeStyles/Project.xml b/virtuerl/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..919ce1f --- /dev/null +++ b/virtuerl/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/virtuerl/.idea/codeStyles/codeStyleConfig.xml b/virtuerl/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/virtuerl/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/virtuerl/.idea/compiler.xml b/virtuerl/.idea/compiler.xml new file mode 100644 index 0000000..bfeea2e --- /dev/null +++ b/virtuerl/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file diff --git a/virtuerl/.idea/modules.xml b/virtuerl/.idea/modules.xml new file mode 100644 index 0000000..540417d --- /dev/null +++ b/virtuerl/.idea/modules.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/virtuerl/.idea/vcs.xml b/virtuerl/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/virtuerl/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/virtuerl/LICENSE.md b/virtuerl/LICENSE.md new file mode 100644 index 0000000..b1ceda4 --- /dev/null +++ b/virtuerl/LICENSE.md @@ -0,0 +1,186 @@ +# Apache License +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +## 1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +## 2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +## 3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +## 4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +1. You must give any other recipients of the Work or Derivative Works a copy of + this License; and + +2. You must cause any modified files to carry prominent notices stating that + You changed the files; and + +3. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain to + any part of the Derivative Works; and + +4. If the Work includes a "NOTICE" text file as part of its distribution, then + any Derivative Works that You distribute must include a readable copy of the + attribution notices contained within such NOTICE file, excluding those + notices that do not pertain to any part of the Derivative Works, in at least + one of the following places: within a NOTICE text file distributed as part + of the Derivative Works; within the Source form or documentation, if + provided along with the Derivative Works; or, within a display generated by + the Derivative Works, if and wherever such third-party notices normally + appear. The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum to + the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +## 5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +## 6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +## 7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, NON- +INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +## 8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +## 9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +Copyright 2023, Ilya Verbitskiy . + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/virtuerl/README.md b/virtuerl/README.md new file mode 100644 index 0000000..7d35a3f --- /dev/null +++ b/virtuerl/README.md @@ -0,0 +1,9 @@ +virtuerl +===== + +An OTP application + +Build +----- + + $ rebar3 compile diff --git a/virtuerl/Vagrantfile b/virtuerl/Vagrantfile new file mode 100644 index 0000000..543bf43 --- /dev/null +++ b/virtuerl/Vagrantfile @@ -0,0 +1,77 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "debian/bookworm64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "../", "/restvirt" + + # Disable the default share of the current code directory. Doing this + # provides improved isolation between the vagrant box and your host + # by making sure your Vagrantfile isn't accessable to the vagrant box. + # If you use this you may want to enable additional shared subfolders as + # shown above. + config.vm.synced_folder ".", "/vagrant", disabled: true + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # Customize the amount of memory on the VM: + vb.memory = "1024" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL +end diff --git a/virtuerl/bird.conf b/virtuerl/bird.conf new file mode 100644 index 0000000..4351773 --- /dev/null +++ b/virtuerl/bird.conf @@ -0,0 +1,171 @@ +# This is a basic configuration file, which contains boilerplate options and +# some basic examples. It allows the BIRD daemon to start but will not cause +# anything else to happen. +# +# Please refer to the BIRD User's Guide documentation, which is also available +# online at http://bird.network.cz/ in HTML format, for more information on +# configuring BIRD and adding routing protocols. + +# Configure logging +# log syslog all; +log stderr all; +# log "/var/log/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug }; + +# Set router ID. It is a unique identification of your router, usually one of +# IPv4 addresses of the router. It is recommended to configure it explicitly. +# router id 198.51.100.1; + +# Turn on global debugging of all protocols (all messages or just selected classes) +# debug protocols all; +# debug protocols { events, states }; + +# Turn on internal watchdog +# watchdog warning 5 s; +# watchdog timeout 30 s; + +# You can define your own constants +# define my_asn = 65000; +# define my_addr = 198.51.100.1; + +# Tables master4 and master6 are defined by default +# ipv4 table master4; +# ipv6 table master6; + +# Define more tables, e.g. for policy routing or as MRIB +# ipv4 table mrib4; +# ipv6 table mrib6; + +# The Device protocol is not a real routing protocol. It does not generate any +# routes and it only serves as a module for getting information about network +# interfaces from the kernel. It is necessary in almost any configuration. +protocol device { +} + +# The direct protocol is not a real routing protocol. It automatically generates +# direct routes to all network interfaces. Can exist in as many instances as you +# wish if you want to populate multiple routing tables with direct routes. +protocol direct { + disabled; # Disable by default + ipv4; # Connect to default IPv4 table + ipv6; # ... and to default IPv6 table +} + +# The Kernel protocol is not a real routing protocol. Instead of communicating +# with other routers in the network, it performs synchronization of BIRD +# routing tables with the OS kernel. One instance per table. +protocol kernel { + ipv4 { # Connect protocol to IPv4 table by channel +# table master4; # Default IPv4 table is master4 +# import all; # Import to table, default is import all + export all; # Export to protocol. default is export none + }; +# learn; # Learn alien routes from the kernel +# kernel table 10; # Kernel table to synchronize with (default: main) +} + +# Another instance for IPv6, skipping default options +protocol kernel { + ipv6 { export all; }; +} + +# Static routes (Again, there can be multiple instances, for different address +# families and to disable/enable various groups of static routes on the fly). +protocol static { + ipv4; # Again, IPv4 channel with default options + +# route 0.0.0.0/0 via 198.51.100.10; +# route 192.0.2.0/24 blackhole; +# route 10.0.0.0/8 unreachable; +# route 10.2.0.0/24 via "eth0"; +# # Static routes can be defined with optional attributes +# route 10.1.1.0/24 via 198.51.100.3 { rip_metric = 3; }; +# route 10.1.2.0/24 via 198.51.100.3 { ospf_metric1 = 100; }; +# route 10.1.3.0/24 via 198.51.100.4 { ospf_metric2 = 100; }; +} + +include "birderl.conf"; + +protocol bgp { + local as 65000 port 9179; + neighbor range 192.168.0.0/16 as 65001; + passive; + ipv4 { + import all; + export all; + }; +} + +# Define simple filter as an example for BGP import filter +# See https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering for more examples +# filter rt_import +# { +# if bgp_path.first != 64496 then accept; +# if bgp_path.len > 64 then accept; +# if bgp_next_hop != from then accept; +# reject; +# } + +# BGP example, explicit name 'uplink1' is used instead of default 'bgp1' +# protocol bgp uplink1 { +# description "My BGP uplink"; +# local 198.51.100.1 as 65000; +# neighbor 198.51.100.10 as 64496; +# hold time 90; # Default is 240 +# password "secret"; # Password used for MD5 authentication +# +# ipv4 { # regular IPv4 unicast (1/1) +# import filter rt_import; +# export where source ~ [ RTS_STATIC, RTS_BGP ]; +# }; +# +# ipv6 { # regular IPv6 unicast (2/1) +# import filter rt_import; +# export filter { # The same as 'where' expression above +# if source ~ [ RTS_STATIC, RTS_BGP ] +# then accept; +# else reject; +# }; +# }; +# +# ipv4 multicast { # IPv4 multicast topology (1/2) +# table mrib4; # explicit IPv4 table +# import filter rt_import; +# export all; +# }; +# +# ipv6 multicast { # IPv6 multicast topology (2/2) +# table mrib6; # explicit IPv6 table +# import filter rt_import; +# export all; +# }; +#} + +# Template example. Using templates to define IBGP route reflector clients. +# template bgp rr_clients { +# local 10.0.0.1 as 65000; +# neighbor as 65000; +# rr client; +# rr cluster id 1.0.0.1; +# +# ipv4 { +# import all; +# export where source = RTS_BGP; +# }; +# +# ipv6 { +# import all; +# export where source = RTS_BGP; +# }; +# } +# +# protocol bgp client1 from rr_clients { +# neighbor 10.0.1.1; +# } +# +# protocol bgp client2 from rr_clients { +# neighbor 10.0.2.1; +# } +# +# protocol bgp client3 from rr_clients { +# neighbor 10.0.3.1; +# } diff --git a/virtuerl/config/sys.config b/virtuerl/config/sys.config new file mode 100644 index 0000000..9cd128b --- /dev/null +++ b/virtuerl/config/sys.config @@ -0,0 +1,15 @@ +[{kernel, + [{logger_level, all}, + {logger, + [{handler, default, logger_std_h, + #{ level => info, + formatter => {logger_formatter, #{single_line => false}}}} + ]}]}, + {grpcbox, [ + {client, #{channels => [{default_channel, [{https, "verbit.in-berlin.de", 8443, [ + {certfile, "config/client.crt"}, + {keyfile, "config/client.key"}, + {cacertfile, "config/ca.crt"} + ]}], #{}}]}} + ]} +]. diff --git a/virtuerl/erlang_ls.config b/virtuerl/erlang_ls.config new file mode 100644 index 0000000..d7edc4a --- /dev/null +++ b/virtuerl/erlang_ls.config @@ -0,0 +1,9 @@ +apps_dirs: + - "_build/default/lib/*" +include_dirs: + - "include" + - "_build/default/lib/*/include" + - "_build/default/lib" + - "_build/default/lib/khepri" +deps_dirs: + - "_build/default/lib/*" diff --git a/virtuerl/rebar.config b/virtuerl/rebar.config new file mode 100644 index 0000000..0ec98a0 --- /dev/null +++ b/virtuerl/rebar.config @@ -0,0 +1,20 @@ +{erl_opts, [debug_info]}. +{deps, [ + {khepri, "0.7.0"}, + {thoas, "1.0.0"}, + {grpcbox, "0.16.0"}, + {cowboy, "2.10.0"}, + {mochiweb, "3.1.2"} +]}. + +{plugins, [grpcbox_plugin]}. +{grpc, [ + {out_dir, "src/pb"}, + {protos, "../protos/minivirt"}, + {gpb_opts, [{module_name_suffix, "_pb"}, {i, "../protos"}, {o, "src/pb"}]} + ]}. + +{shell, [ + {config, "config/sys.config"}, + {apps, [virtuerl]} +]}. diff --git a/virtuerl/rebar.lock b/virtuerl/rebar.lock new file mode 100644 index 0000000..21dace2 --- /dev/null +++ b/virtuerl/rebar.lock @@ -0,0 +1,56 @@ +{"1.2.0", +[{<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},1}, + {<<"aten">>,{pkg,<<"aten">>,<<"0.5.8">>},2}, + {<<"chatterbox">>,{pkg,<<"ts_chatterbox">>,<<"0.13.0">>},1}, + {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.10.0">>},0}, + {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.12.1">>},1}, + {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},1}, + {<<"gen_batch_server">>,{pkg,<<"gen_batch_server">>,<<"0.8.8">>},2}, + {<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1}, + {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.16.0">>},0}, + {<<"horus">>,{pkg,<<"horus">>,<<"0.2.3">>},1}, + {<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},2}, + {<<"khepri">>,{pkg,<<"khepri">>,<<"0.7.0">>},0}, + {<<"mochiweb">>,{pkg,<<"mochiweb">>,<<"3.1.2">>},0}, + {<<"ra">>,{pkg,<<"ra">>,<<"2.5.1">>},1}, + {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, + {<<"seshat">>,{pkg,<<"seshat">>,<<"0.4.0">>},2}, + {<<"thoas">>,{pkg,<<"thoas">>,<<"1.0.0">>},0}]}. +[ +{pkg_hash,[ + {<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>}, + {<<"aten">>, <<"B5C97F48517C4F37F26A519AA57A00A31FF1B8EA4324EC1CAE27F818ED5C0DB2">>}, + {<<"chatterbox">>, <<"6F059D97BCAA758B8EA6FFFE2B3B81362BD06B639D3EA2BB088335511D691EBF">>}, + {<<"cowboy">>, <<"FF9FFEFF91DAE4AE270DD975642997AFE2A1179D94B1887863E43F681A203E26">>}, + {<<"cowlib">>, <<"A9FA9A625F1D2025FE6B462CB865881329B5CAFF8F1854D1CBC9F9533F00E1E1">>}, + {<<"ctx">>, <<"8FF88B70E6400C4DF90142E7F130625B82086077A45364A78D208ED3ED53C7FE">>}, + {<<"gen_batch_server">>, <<"7840A1FA63EE1EFFC83E8A91D22664847A2BA1192D30EAFFFD914ACB51578068">>}, + {<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>}, + {<<"grpcbox">>, <<"B83F37C62D6EECA347B77F9B1EC7E9F62231690CDFEB3A31BE07CD4002BA9C82">>}, + {<<"horus">>, <<"A8AC0E7B335B83860ECECFA12EE4CB50289A15A515175BEF804A9C0D06C619B5">>}, + {<<"hpack">>, <<"17670F83FF984AE6CD74B1C456EDDE906D27FF013740EE4D9EFAA4F1BF999633">>}, + {<<"khepri">>, <<"5CB9B1D35051DAEAF6308BFC64446A4BC2DEAAAE39C619DFB890B6CCFF8F45AF">>}, + {<<"mochiweb">>, <<"D872D470DBBA367171A38C41592B19DE370854E74C8621BF0C6FE39B17CDD1CF">>}, + {<<"ra">>, <<"9EE208B7CD229B34F67C56B6BEFAD0E906C5B37C6175DB9C76C00B1BC0CF82D8">>}, + {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, + {<<"seshat">>, <<"1D5DC4294E36B8745245AB2649E24E39D7B6B1209D7A6484F2B8D706C35C9814">>}, + {<<"thoas">>, <<"567C03902920827A18A89F05B79A37B5BF93553154B883E0131801600CF02CE0">>}]}, +{pkg_hash_ext,[ + {<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>}, + {<<"aten">>, <<"64D40A8CF0DDFEA4E13AF00B7327F0925147F83612D0627D9506CBFFE90C13EF">>}, + {<<"chatterbox">>, <<"B93D19104D86AF0B3F2566C4CBA2A57D2E06D103728246BA1AC6C3C0FF010AA7">>}, + {<<"cowboy">>, <<"3AFDCCB7183CC6F143CB14D3CF51FA00E53DB9EC80CDCD525482F5E99BC41D6B">>}, + {<<"cowlib">>, <<"163B73F6367A7341B33C794C4E88E7DBFE6498AC42DCD69EF44C5BC5507C8DB0">>}, + {<<"ctx">>, <<"A14ED2D1B67723DBEBBE423B28D7615EB0BDCBA6FF28F2D1F1B0A7E1D4AA5FC2">>}, + {<<"gen_batch_server">>, <<"C3E6A1A2A0FB62AEE631A98CFA0FD8903E9562422CBF72043953E2FB1D203017">>}, + {<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>}, + {<<"grpcbox">>, <<"294DF743AE20A7E030889F00644001370A4F7CE0121F3BBDAF13CF3169C62913">>}, + {<<"horus">>, <<"0CA6AA70A348F73EF0B78F498C82F9C29F49B45D5915B890945A1C326A216C10">>}, + {<<"hpack">>, <<"06F580167C4B8B8A6429040DF36CC93BBA6D571FAEAEC1B28816523379CBB23A">>}, + {<<"khepri">>, <<"784D90A578340E137BF7E2C8D1F1F45E59D6E13262804A841BF9E709E7505954">>}, + {<<"mochiweb">>, <<"A8609035711F9264E8ABE54312D1B1645374B9E08986AE06E979BB0AC8B99F9F">>}, + {<<"ra">>, <<"13B03F02CF6C1837C527EDD4A953F0C09DA0ABAD0AF6985B64BFD66943C4C5C3">>}, + {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, + {<<"seshat">>, <<"2C3DEEC7FF86E0D0C05EDEBD3455C8363123C227BE292FFFFC1A05EEC08BFF63">>}, + {<<"thoas">>, <<"FC763185B932ECB32A554FB735EE03C3B6B1B31366077A2427D2A97F3BD26735">>}]} +]. diff --git a/virtuerl/src/pb/controller_pb.erl b/virtuerl/src/pb/controller_pb.erl new file mode 100644 index 0000000..f6bad6d --- /dev/null +++ b/virtuerl/src/pb/controller_pb.erl @@ -0,0 +1,8217 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(controller_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type empty() :: + #{ + }. + +-type sync_routes_request() :: + #{ + }. + +-type start_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata() % = 2, optional + }. + +-type stop_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata(), % = 2, optional + force => boolean() | 0 | 1 % = 3, optional + }. + +-type get_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type domain() :: + #{id => non_neg_integer(), % = 1, optional, 64 bits + uuid => unicode:chardata(), % = 2, optional + name => unicode:chardata(), % = 3, optional + vcpu => non_neg_integer(), % = 4, optional, 32 bits + memory => non_neg_integer(), % = 5, optional, 64 bits + network => unicode:chardata(), % = 6, optional + bridge => unicode:chardata(), % = 7, optional + state => unicode:chardata(), % = 8, optional + private_ip => unicode:chardata(), % = 9, optional + ipv6_address => unicode:chardata(), % = 15, optional + user_data => unicode:chardata(), % = 10, optional + nested_virtualization => boolean() | 0 | 1, % = 11, optional + base_image => unicode:chardata(), % = 12, optional + created_at => timestamp(), % = 13, optional + os_type => unicode:chardata() % = 14, optional + }. + +-type list_domains_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_domains_response() :: + #{domains => [domain()] % = 1, repeated + }. + +-type create_domain_request() :: + #{domain => domain(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type download_image_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type image_chunk() :: + #{bytes => iodata() % = 1, optional + }. + +-type get_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type network() :: + #{uuid => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + cidr => unicode:chardata(), % = 3, optional + cidr6 => unicode:chardata() % = 4, optional + }. + +-type list_networks_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_networks_response() :: + #{networks => [network()] % = 1, repeated + }. + +-type create_network_request() :: + #{network => network(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type get_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume() :: + #{id => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + size => non_neg_integer() % = 3, optional, 64 bits + }. + +-type list_volumes_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_volumes_response() :: + #{volumes => [volume()] % = 1, repeated + }. + +-type create_volume_request() :: + #{volume => volume(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type update_volume_request() :: + #{host => unicode:chardata(), % = 1, optional + volume => volume() % = 2, optional + }. + +-type delete_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume_attachment_identifier() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + host => unicode:chardata() % = 3, optional + }. + +-type volume_attachment() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + disk_address => unicode:chardata() % = 3, optional + }. + +-type list_volume_attachments_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type list_volume_attachments_response() :: + #{attachments => [volume_attachment()] % = 1, repeated + }. + +-type port_forwarding_identifier() :: + #{host => unicode:chardata(), % = 1, optional + protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer() % = 3, optional, 32 bits + }. + +-type port_forwarding() :: + #{protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer(), % = 3, optional, 32 bits + target_ip => unicode:chardata(), % = 4, optional + target_port => non_neg_integer() % = 5, optional, 32 bits + }. + +-type list_port_forwardings_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_port_forwardings_response() :: + #{port_forwardings => [port_forwarding()] % = 1, repeated + }. + +-type put_port_forwarding_request() :: + #{port_forwarding => port_forwarding(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type dns_record_identifier() :: + #{name => unicode:chardata(), % = 1, optional + type => unicode:chardata() % = 2, optional + }. + +-type dns_record() :: + #{name => unicode:chardata(), % = 1, optional + type => unicode:chardata(), % = 2, optional + ttl => non_neg_integer(), % = 3, optional, 64 bits + records => [unicode:chardata()] % = 4, repeated + }. + +-type list_dns_records_request() :: + #{ + }. + +-type list_dns_records_response() :: + #{dns_records => [dns_record()] % = 1, repeated + }. + +-type put_dns_record_request() :: + #{dns_record => dns_record() % = 1, optional + }. + +-type route_table() :: + #{network_name => unicode:chardata(), % = 1, optional + id => non_neg_integer(), % = 2, optional, 32 bits + name => unicode:chardata() % = 3, optional + }. + +-type route_table_identifier() :: + #{id => non_neg_integer() % = 1, optional, 32 bits + }. + +-type list_route_tables_request() :: + #{network_name => unicode:chardata() % = 1, optional + }. + +-type list_route_tables_response() :: + #{route_tables => [route_table()] % = 1, repeated + }. + +-type create_route_table_request() :: + #{route_table => route_table() % = 1, optional + }. + +-type route_identifier() :: + #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits + destination => unicode:chardata() % = 2, optional + }. + +-type route() :: + #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits + destination => unicode:chardata(), % = 2, optional + gateways => [unicode:chardata()] % = 3, repeated + }. + +-type list_routes_request() :: + #{route_table_id => non_neg_integer() % = 1, optional, 32 bits + }. + +-type list_routes_response() :: + #{routes => [route()] % = 1, repeated + }. + +-type put_route_request() :: + #{route => route() % = 1, optional + }. + +-type sync_request() :: + #{ + }. + +-type timestamp() :: + #{seconds => integer(), % = 1, optional, 64 bits + nanos => integer() % = 2, optional, 32 bits + }. + +-export_type(['empty'/0, 'sync_routes_request'/0, 'start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'dns_record_identifier'/0, 'dns_record'/0, 'list_dns_records_request'/0, 'list_dns_records_response'/0, 'put_dns_record_request'/0, 'route_table'/0, 'route_table_identifier'/0, 'list_route_tables_request'/0, 'list_route_tables_response'/0, 'create_route_table_request'/0, 'route_identifier'/0, 'route'/0, 'list_routes_request'/0, 'list_routes_response'/0, 'put_route_request'/0, 'sync_request'/0, 'timestamp'/0]). +-type '$msg_name'() :: empty | sync_routes_request | start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | dns_record_identifier | dns_record | list_dns_records_request | list_dns_records_response | put_dns_record_request | route_table | route_table_identifier | list_route_tables_request | list_route_tables_response | create_route_table_request | route_identifier | route | list_routes_request | list_routes_response | put_route_request | sync_request | timestamp. +-type '$msg'() :: empty() | sync_routes_request() | start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | dns_record_identifier() | dns_record() | list_dns_records_request() | list_dns_records_response() | put_dns_record_request() | route_table() | route_table_identifier() | list_route_tables_request() | list_route_tables_response() | create_route_table_request() | route_identifier() | route() | list_routes_request() | list_routes_response() | put_route_request() | sync_request() | timestamp(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); + sync_routes_request -> encode_msg_sync_routes_request(id(Msg, TrUserData), TrUserData); + start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); + stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); + get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); + domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); + list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); + list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); + create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); + delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); + download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); + image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); + get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); + network -> encode_msg_network(id(Msg, TrUserData), TrUserData); + list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); + list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); + create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); + delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); + get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); + volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); + list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); + list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); + create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); + update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); + delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); + volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); + volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); + list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); + list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); + port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); + port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); + list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); + list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); + put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); + dns_record_identifier -> encode_msg_dns_record_identifier(id(Msg, TrUserData), TrUserData); + dns_record -> encode_msg_dns_record(id(Msg, TrUserData), TrUserData); + list_dns_records_request -> encode_msg_list_dns_records_request(id(Msg, TrUserData), TrUserData); + list_dns_records_response -> encode_msg_list_dns_records_response(id(Msg, TrUserData), TrUserData); + put_dns_record_request -> encode_msg_put_dns_record_request(id(Msg, TrUserData), TrUserData); + route_table -> encode_msg_route_table(id(Msg, TrUserData), TrUserData); + route_table_identifier -> encode_msg_route_table_identifier(id(Msg, TrUserData), TrUserData); + list_route_tables_request -> encode_msg_list_route_tables_request(id(Msg, TrUserData), TrUserData); + list_route_tables_response -> encode_msg_list_route_tables_response(id(Msg, TrUserData), TrUserData); + create_route_table_request -> encode_msg_create_route_table_request(id(Msg, TrUserData), TrUserData); + route_identifier -> encode_msg_route_identifier(id(Msg, TrUserData), TrUserData); + route -> encode_msg_route(id(Msg, TrUserData), TrUserData); + list_routes_request -> encode_msg_list_routes_request(id(Msg, TrUserData), TrUserData); + list_routes_response -> encode_msg_list_routes_response(id(Msg, TrUserData), TrUserData); + put_route_request -> encode_msg_put_route_request(id(Msg, TrUserData), TrUserData); + sync_request -> encode_msg_sync_request(id(Msg, TrUserData), TrUserData); + timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +encode_msg_sync_routes_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{force := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= false -> B2; + true -> e_type_bool(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). + + +encode_msg_domain(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{name := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + B4 = case M of + #{vcpu := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end, + B5 = case M of + #{memory := F5} -> + begin + TrF5 = id(F5, TrUserData), + if TrF5 =:= 0 -> B4; + true -> e_varint(TrF5, <>, TrUserData) + end + end; + _ -> B4 + end, + B6 = case M of + #{network := F6} -> + begin + TrF6 = id(F6, TrUserData), + case is_empty_string(TrF6) of + true -> B5; + false -> e_type_string(TrF6, <>, TrUserData) + end + end; + _ -> B5 + end, + B7 = case M of + #{bridge := F7} -> + begin + TrF7 = id(F7, TrUserData), + case is_empty_string(TrF7) of + true -> B6; + false -> e_type_string(TrF7, <>, TrUserData) + end + end; + _ -> B6 + end, + B8 = case M of + #{state := F8} -> + begin + TrF8 = id(F8, TrUserData), + case is_empty_string(TrF8) of + true -> B7; + false -> e_type_string(TrF8, <>, TrUserData) + end + end; + _ -> B7 + end, + B9 = case M of + #{private_ip := F9} -> + begin + TrF9 = id(F9, TrUserData), + case is_empty_string(TrF9) of + true -> B8; + false -> e_type_string(TrF9, <>, TrUserData) + end + end; + _ -> B8 + end, + B10 = case M of + #{ipv6_address := F10} -> + begin + TrF10 = id(F10, TrUserData), + case is_empty_string(TrF10) of + true -> B9; + false -> e_type_string(TrF10, <>, TrUserData) + end + end; + _ -> B9 + end, + B11 = case M of + #{user_data := F11} -> + begin + TrF11 = id(F11, TrUserData), + case is_empty_string(TrF11) of + true -> B10; + false -> e_type_string(TrF11, <>, TrUserData) + end + end; + _ -> B10 + end, + B12 = case M of + #{nested_virtualization := F12} -> + begin + TrF12 = id(F12, TrUserData), + if TrF12 =:= false -> B11; + true -> e_type_bool(TrF12, <>, TrUserData) + end + end; + _ -> B11 + end, + B13 = case M of + #{base_image := F13} -> + begin + TrF13 = id(F13, TrUserData), + case is_empty_string(TrF13) of + true -> B12; + false -> e_type_string(TrF13, <>, TrUserData) + end + end; + _ -> B12 + end, + B14 = case M of + #{created_at := F14} -> + begin + TrF14 = id(F14, TrUserData), + if TrF14 =:= undefined -> B13; + true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) + end + end; + _ -> B13 + end, + case M of + #{os_type := F15} -> + begin + TrF15 = id(F15, TrUserData), + case is_empty_string(TrF15) of + true -> B14; + false -> e_type_string(TrF15, <>, TrUserData) + end + end; + _ -> B14 + end. + +encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> + case M of + #{domains := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). + + +encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). + + +encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> + case M of + #{bytes := F1} -> + begin + TrF1 = id(F1, TrUserData), + case iolist_size(TrF1) of + 0 -> Bin; + _ -> e_type_bytes(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). + + +encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). + + +encode_msg_network(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{cidr := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{cidr6 := F4} -> + begin + TrF4 = id(F4, TrUserData), + case is_empty_string(TrF4) of + true -> B3; + false -> e_type_string(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> + case M of + #{networks := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). + + +encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{network := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). + + +encode_msg_volume(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{size := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> + case M of + #{volumes := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{volume := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{volume := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= undefined -> B1; + true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{host := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{disk_address := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> + case M of + #{attachments := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{protocol := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{source_port := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{protocol := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{source_port := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_varint(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{target_ip := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{target_port := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> + case M of + #{port_forwardings := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). + + +encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{port_forwarding := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_dns_record_identifier(Msg, TrUserData) -> encode_msg_dns_record_identifier(Msg, <<>>, TrUserData). + + +encode_msg_dns_record_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{type := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_dns_record(Msg, TrUserData) -> encode_msg_dns_record(Msg, <<>>, TrUserData). + + +encode_msg_dns_record(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{type := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{ttl := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{records := F4} -> + TrF4 = id(F4, TrUserData), + if TrF4 == [] -> B3; + true -> e_field_dns_record_records(TrF4, B3, TrUserData) + end; + _ -> B3 + end. + +encode_msg_list_dns_records_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_list_dns_records_response(Msg, TrUserData) -> encode_msg_list_dns_records_response(Msg, <<>>, TrUserData). + + +encode_msg_list_dns_records_response(#{} = M, Bin, TrUserData) -> + case M of + #{dns_records := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_dns_records_response_dns_records(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_dns_record_request(Msg, TrUserData) -> encode_msg_put_dns_record_request(Msg, <<>>, TrUserData). + + +encode_msg_put_dns_record_request(#{} = M, Bin, TrUserData) -> + case M of + #{dns_record := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_dns_record_request_dns_record(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_route_table(Msg, TrUserData) -> encode_msg_route_table(Msg, <<>>, TrUserData). + + +encode_msg_route_table(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{network_name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{id := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_varint(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{name := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_route_table_identifier(Msg, TrUserData) -> encode_msg_route_table_identifier(Msg, <<>>, TrUserData). + + +encode_msg_route_table_identifier(#{} = M, Bin, TrUserData) -> + case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_route_tables_request(Msg, TrUserData) -> encode_msg_list_route_tables_request(Msg, <<>>, TrUserData). + + +encode_msg_list_route_tables_request(#{} = M, Bin, TrUserData) -> + case M of + #{network_name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_route_tables_response(Msg, TrUserData) -> encode_msg_list_route_tables_response(Msg, <<>>, TrUserData). + + +encode_msg_list_route_tables_response(#{} = M, Bin, TrUserData) -> + case M of + #{route_tables := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_route_tables_response_route_tables(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_route_table_request(Msg, TrUserData) -> encode_msg_create_route_table_request(Msg, <<>>, TrUserData). + + +encode_msg_create_route_table_request(#{} = M, Bin, TrUserData) -> + case M of + #{route_table := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_route_table_request_route_table(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_route_identifier(Msg, TrUserData) -> encode_msg_route_identifier(Msg, <<>>, TrUserData). + + +encode_msg_route_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{destination := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_route(Msg, TrUserData) -> encode_msg_route(Msg, <<>>, TrUserData). + + +encode_msg_route(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{destination := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{gateways := F3} -> + TrF3 = id(F3, TrUserData), + if TrF3 == [] -> B2; + true -> e_field_route_gateways(TrF3, B2, TrUserData) + end; + _ -> B2 + end. + +encode_msg_list_routes_request(Msg, TrUserData) -> encode_msg_list_routes_request(Msg, <<>>, TrUserData). + + +encode_msg_list_routes_request(#{} = M, Bin, TrUserData) -> + case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_routes_response(Msg, TrUserData) -> encode_msg_list_routes_response(Msg, <<>>, TrUserData). + + +encode_msg_list_routes_response(#{} = M, Bin, TrUserData) -> + case M of + #{routes := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_routes_response_routes(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_route_request(Msg, TrUserData) -> encode_msg_put_route_request(Msg, <<>>, TrUserData). + + +encode_msg_put_route_request(#{} = M, Bin, TrUserData) -> + case M of + #{route := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_route_request_route(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_sync_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). + + +encode_msg_timestamp(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{seconds := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_type_int64(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{nanos := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_type_int32(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +e_mfield_domain_created_at(Msg, Bin, TrUserData) -> + SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_domains_response_domains(Rest, Bin3, TrUserData); +e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. + +e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_networks_response_networks(Rest, Bin3, TrUserData); +e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. + +e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); +e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. + +e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); +e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. + +e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); +e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. + +e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_dns_record_records([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), + e_field_dns_record_records(Rest, Bin3, TrUserData); +e_field_dns_record_records([], Bin, _TrUserData) -> Bin. + +e_mfield_list_dns_records_response_dns_records(Msg, Bin, TrUserData) -> + SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_dns_records_response_dns_records([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_dns_records_response_dns_records(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_dns_records_response_dns_records(Rest, Bin3, TrUserData); +e_field_list_dns_records_response_dns_records([], Bin, _TrUserData) -> Bin. + +e_mfield_put_dns_record_request_dns_record(Msg, Bin, TrUserData) -> + SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_route_tables_response_route_tables(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_route_tables_response_route_tables([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_route_tables_response_route_tables(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_route_tables_response_route_tables(Rest, Bin3, TrUserData); +e_field_list_route_tables_response_route_tables([], Bin, _TrUserData) -> Bin. + +e_mfield_create_route_table_request_route_table(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_route_gateways([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), + e_field_route_gateways(Rest, Bin3, TrUserData); +e_field_route_gateways([], Bin, _TrUserData) -> Bin. + +e_mfield_list_routes_response_routes(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_routes_response_routes([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_routes_response_routes(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_routes_response_routes(Rest, Bin3, TrUserData); +e_field_list_routes_response_routes([], Bin, _TrUserData) -> Bin. + +e_mfield_put_route_request_route(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); +decode_msg_2_doit(sync_routes_request, Bin, TrUserData) -> id(decode_msg_sync_routes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(dns_record_identifier, Bin, TrUserData) -> id(decode_msg_dns_record_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(dns_record, Bin, TrUserData) -> id(decode_msg_dns_record(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_dns_records_request, Bin, TrUserData) -> id(decode_msg_list_dns_records_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_dns_records_response, Bin, TrUserData) -> id(decode_msg_list_dns_records_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_dns_record_request, Bin, TrUserData) -> id(decode_msg_put_dns_record_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route_table, Bin, TrUserData) -> id(decode_msg_route_table(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route_table_identifier, Bin, TrUserData) -> id(decode_msg_route_table_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_route_tables_request, Bin, TrUserData) -> id(decode_msg_list_route_tables_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_route_tables_response, Bin, TrUserData) -> id(decode_msg_list_route_tables_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_route_table_request, Bin, TrUserData) -> id(decode_msg_create_route_table_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route_identifier, Bin, TrUserData) -> id(decode_msg_route_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route, Bin, TrUserData) -> id(decode_msg_route(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_routes_request, Bin, TrUserData) -> id(decode_msg_list_routes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_routes_response, Bin, TrUserData) -> id(decode_msg_list_routes_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_route_request, Bin, TrUserData) -> id(decode_msg_put_route_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(sync_request, Bin, TrUserData) -> id(decode_msg_sync_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). + + + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +decode_msg_sync_routes_request(Bin, TrUserData) -> dfp_read_field_def_sync_routes_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_sync_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_routes_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_sync_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_sync_routes_request(Rest2, 0, 0, F, TrUserData). + +skip_group_sync_routes_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_sync_routes_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_sync_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_sync_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; +dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. + +d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). + +dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; +dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. + +d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_domain(Bin, TrUserData) -> + dfp_read_field_def_domain(Bin, + 0, + 0, + 0, + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(0, TrUserData), + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(false, TrUserData), + id(<<>>, TrUserData), + id('$undef', TrUserData), + id(<<>>, TrUserData), + TrUserData). + +dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end; +dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> + dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) + end + end; +dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end. + +d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). + +d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, + 0, + 0, + F, + F@_1, + F@_2, + F@_3, + F@_4, + F@_5, + F@_6, + F@_7, + F@_8, + F@_9, + F@_10, + F@_11, + F@_12, + F@_13, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) + end, + F@_15, + TrUserData). + +d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). + +skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end. + +d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end; +dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end. + +d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_domain(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; +dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. + +d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; +dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. + +d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end. + +d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end; +dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end. + +d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_network(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; +dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. + +d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end; +dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end. + +d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end; +dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end. + +d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, + 0, + 0, + F, + F@_1, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; +dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. + +d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; +dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. + +d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; +dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. + +d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; +dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. + +d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end. + +d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end; +dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end. + +d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_dns_record_identifier(Bin, TrUserData) -> dfp_read_field_def_dns_record_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_dns_record_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_dns_record_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_type(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}; +dfp_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_dns_record_identifier_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_dns_record_identifier_type(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}. + +d_field_dns_record_identifier_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_dns_record_identifier_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_dns_record_identifier_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_dns_record_identifier_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_dns_record_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_dns_record_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_dns_record_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_dns_record_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_dns_record_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_dns_record_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_dns_record_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_dns_record(Bin, TrUserData) -> dfp_read_field_def_dns_record(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id([], TrUserData), TrUserData). + +dfp_read_field_def_dns_record(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_ttl(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_records(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}; +dfp_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_dns_record_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 18 -> d_field_dns_record_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 24 -> d_field_dns_record_ttl(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_dns_record_records(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}. + +d_field_dns_record_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_dns_record_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_dns_record_ttl(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_ttl(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_ttl(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_dns_record_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_records(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, F@_3, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_dns_record(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_dns_record(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_dns_record(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_dns_record(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_dns_record(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_dns_record(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_dns_record(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_dns_records_request(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_list_dns_records_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_dns_records_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_list_dns_records_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_dns_records_request(Rest2, 0, 0, F, TrUserData). + +skip_group_list_dns_records_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_dns_records_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_list_dns_records_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_list_dns_records_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_list_dns_records_response(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_dns_records_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_dns_records_response_dns_records(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{dns_records => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_dns_records_response_dns_records(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{dns_records => lists_reverse(R1, TrUserData)} + end. + +d_field_list_dns_records_response_dns_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_dns_records_response_dns_records(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_dns_records_response_dns_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_dns_records_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_dns_records_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_dns_records_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_dns_records_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_dns_records_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_dns_records_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_dns_records_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_dns_records_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_dns_record_request(Bin, TrUserData) -> dfp_read_field_def_put_dns_record_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_put_dns_record_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_dns_record_request_dns_record(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{dns_record => F@_1} + end; +dfp_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_dns_record_request_dns_record(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{dns_record => F@_1} + end. + +d_field_put_dns_record_request_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_dns_record_request_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_put_dns_record_request_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_dns_record_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_dns_record(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_put_dns_record_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_put_dns_record_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_dns_record_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_put_dns_record_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_dns_record_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_put_dns_record_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_put_dns_record_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_route_table(Bin, TrUserData) -> dfp_read_field_def_route_table(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_route_table(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}; +dfp_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_route_table_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 16 -> d_field_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_route_table_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}. + +d_field_route_table_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_table(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_route_table_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_route_table(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_route_table(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_table(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_route_table(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_table(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_route_table(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_route_table(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_route_table_identifier(Bin, TrUserData) -> dfp_read_field_def_route_table_identifier(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). + +dfp_read_field_def_route_table_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_route_table_identifier_id(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}; +dfp_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_table_identifier_id(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}. + +d_field_route_table_identifier_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_route_table_identifier_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_route_table_identifier_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_table_identifier(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_route_table_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_route_table_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_table_identifier(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_route_table_identifier(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_table_identifier(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_route_table_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_route_table_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_route_tables_request(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_route_tables_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_request_network_name(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}; +dfp_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_route_tables_request_network_name(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}. + +d_field_list_route_tables_request_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_request_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_route_tables_request_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_route_tables_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_route_tables_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_route_tables_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_route_tables_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_route_tables_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_route_tables_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_route_tables_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_route_tables_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_route_tables_response(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_route_tables_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_response_route_tables(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{route_tables => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_route_tables_response_route_tables(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{route_tables => lists_reverse(R1, TrUserData)} + end. + +d_field_list_route_tables_response_route_tables(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_response_route_tables(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_route_tables_response_route_tables(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_route_tables_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_route_tables_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_route_tables_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_route_tables_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_route_tables_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_route_tables_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_route_tables_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_route_tables_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_route_table_request(Bin, TrUserData) -> dfp_read_field_def_create_route_table_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_create_route_table_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_route_table_request_route_table(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route_table => F@_1} + end; +dfp_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_route_table_request_route_table(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route_table => F@_1} + end. + +d_field_create_route_table_request_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_route_table_request_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_create_route_table_request_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_route_table_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_route_table(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_create_route_table_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_create_route_table_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_route_table_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_create_route_table_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_route_table_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_create_route_table_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_create_route_table_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_route_identifier(Bin, TrUserData) -> dfp_read_field_def_route_identifier(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_route_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_route_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_destination(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}; +dfp_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_identifier_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_route_identifier_destination(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}. + +d_field_route_identifier_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_route_identifier_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_route_identifier_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_route_identifier_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_route_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_route_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_route_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_route_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_route_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_route(Bin, TrUserData) -> dfp_read_field_def_route(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id([], TrUserData), TrUserData). + +dfp_read_field_def_route(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_destination(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_gateways(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}; +dfp_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_route(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_route_destination(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_route_gateways(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}. + +d_field_route_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_route_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_route_gateways(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_gateways(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_gateways(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_route(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_route(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_route(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_route(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_route(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_routes_request(Bin, TrUserData) -> dfp_read_field_def_list_routes_request(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). + +dfp_read_field_def_list_routes_request(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_request_route_table_id(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}; +dfp_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_list_routes_request_route_table_id(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}. + +d_field_list_routes_request_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_request_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_routes_request_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_list_routes_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_routes_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_routes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_routes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_routes_response(Bin, TrUserData) -> dfp_read_field_def_list_routes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_routes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_response_routes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{routes => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_routes_response_routes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{routes => lists_reverse(R1, TrUserData)} + end. + +d_field_list_routes_response_routes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_response_routes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_routes_response_routes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_routes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_routes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_routes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_routes_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_routes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_routes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_routes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_routes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_route_request(Bin, TrUserData) -> dfp_read_field_def_put_route_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_put_route_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_route_request_route(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route => F@_1} + end; +dfp_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_route_request_route(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route => F@_1} + end. + +d_field_put_route_request_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_route_request_route(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_put_route_request_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_route_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_route(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_put_route_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_put_route_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_route_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_put_route_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_route_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_put_route_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_put_route_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_sync_request(Bin, TrUserData) -> dfp_read_field_def_sync_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_sync_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_sync_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_sync_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_sync_request(Rest2, 0, 0, F, TrUserData). + +skip_group_sync_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_sync_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_sync_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_sync_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; +dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. + +d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + empty -> merge_msg_empty(Prev, New, TrUserData); + sync_routes_request -> merge_msg_sync_routes_request(Prev, New, TrUserData); + start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); + stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); + get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); + domain -> merge_msg_domain(Prev, New, TrUserData); + list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); + list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); + create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); + delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); + download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); + image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); + get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); + network -> merge_msg_network(Prev, New, TrUserData); + list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); + list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); + create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); + delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); + get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); + volume -> merge_msg_volume(Prev, New, TrUserData); + list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); + list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); + create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); + update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); + delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); + volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); + volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); + list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); + list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); + port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); + port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); + list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); + list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); + put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); + dns_record_identifier -> merge_msg_dns_record_identifier(Prev, New, TrUserData); + dns_record -> merge_msg_dns_record(Prev, New, TrUserData); + list_dns_records_request -> merge_msg_list_dns_records_request(Prev, New, TrUserData); + list_dns_records_response -> merge_msg_list_dns_records_response(Prev, New, TrUserData); + put_dns_record_request -> merge_msg_put_dns_record_request(Prev, New, TrUserData); + route_table -> merge_msg_route_table(Prev, New, TrUserData); + route_table_identifier -> merge_msg_route_table_identifier(Prev, New, TrUserData); + list_route_tables_request -> merge_msg_list_route_tables_request(Prev, New, TrUserData); + list_route_tables_response -> merge_msg_list_route_tables_response(Prev, New, TrUserData); + create_route_table_request -> merge_msg_create_route_table_request(Prev, New, TrUserData); + route_identifier -> merge_msg_route_identifier(Prev, New, TrUserData); + route -> merge_msg_route(Prev, New, TrUserData); + list_routes_request -> merge_msg_list_routes_request(Prev, New, TrUserData); + list_routes_response -> merge_msg_list_routes_response(Prev, New, TrUserData); + put_route_request -> merge_msg_put_route_request(Prev, New, TrUserData); + sync_request -> merge_msg_sync_request(Prev, New, TrUserData); + timestamp -> merge_msg_timestamp(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_sync_routes_request/3}). +merge_msg_sync_routes_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_start_domain_request/3}). +merge_msg_start_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). +merge_msg_stop_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{force := NFforce}} -> S3#{force => NFforce}; + {#{force := PFforce}, _} -> S3#{force => PFforce}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_get_domain_request/3}). +merge_msg_get_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_domain/3}). +merge_msg_domain(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S3#{name => NFname}; + {#{name := PFname}, _} -> S3#{name => PFname}; + _ -> S3 + end, + S5 = case {PMsg, NMsg} of + {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; + {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; + _ -> S4 + end, + S6 = case {PMsg, NMsg} of + {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; + {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; + _ -> S5 + end, + S7 = case {PMsg, NMsg} of + {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; + _ -> S6 + end, + S8 = case {PMsg, NMsg} of + {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; + {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; + _ -> S7 + end, + S9 = case {PMsg, NMsg} of + {_, #{state := NFstate}} -> S8#{state => NFstate}; + {#{state := PFstate}, _} -> S8#{state => PFstate}; + _ -> S8 + end, + S10 = case {PMsg, NMsg} of + {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; + {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; + _ -> S9 + end, + S11 = case {PMsg, NMsg} of + {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; + {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; + _ -> S10 + end, + S12 = case {PMsg, NMsg} of + {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; + {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; + _ -> S11 + end, + S13 = case {PMsg, NMsg} of + {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; + {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; + _ -> S12 + end, + S14 = case {PMsg, NMsg} of + {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; + {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; + _ -> S13 + end, + S15 = case {PMsg, NMsg} of + {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; + {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; + {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; + {_, _} -> S14 + end, + case {PMsg, NMsg} of + {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; + {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; + _ -> S15 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_request/3}). +merge_msg_list_domains_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_response/3}). +merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; + {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; + {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_domain_request/3}). +merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; + {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; + {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). +merge_msg_delete_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_download_image_request/3}). +merge_msg_download_image_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_image_chunk/3}). +merge_msg_image_chunk(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; + {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_get_network_request/3}). +merge_msg_get_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_network/3}). +merge_msg_network(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; + {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; + {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_request/3}). +merge_msg_list_networks_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_response/3}). +merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; + {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; + {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_network_request/3}). +merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; + {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_network_request/3}). +merge_msg_delete_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_get_volume_request/3}). +merge_msg_get_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume/3}). +merge_msg_volume(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{size := NFsize}} -> S3#{size => NFsize}; + {#{size := PFsize}, _} -> S3#{size => PFsize}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). +merge_msg_list_volumes_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). +merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; + {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; + {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_volume_request/3}). +merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_update_volume_request/3}). +merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; + {_, _} -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). +merge_msg_delete_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). +merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S3#{host => NFhost}; + {#{host := PFhost}, _} -> S3#{host => PFhost}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment/3}). +merge_msg_volume_attachment(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; + {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). +merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). +merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; + {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; + {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). +merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding/3}). +merge_msg_port_forwarding(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; + {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; + {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). +merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). +merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; + {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; + {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). +merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; + {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; + {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_dns_record_identifier/3}). +merge_msg_dns_record_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S1#{name => NFname}; + {#{name := PFname}, _} -> S1#{name => PFname}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{type := NFtype}} -> S2#{type => NFtype}; + {#{type := PFtype}, _} -> S2#{type => PFtype}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_dns_record/3}). +merge_msg_dns_record(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S1#{name => NFname}; + {#{name := PFname}, _} -> S1#{name => PFname}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{type := NFtype}} -> S2#{type => NFtype}; + {#{type := PFtype}, _} -> S2#{type => PFtype}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{ttl := NFttl}} -> S3#{ttl => NFttl}; + {#{ttl := PFttl}, _} -> S3#{ttl => PFttl}; + _ -> S3 + end, + case {PMsg, NMsg} of + {#{records := PFrecords}, #{records := NFrecords}} -> S4#{records => 'erlang_++'(PFrecords, NFrecords, TrUserData)}; + {_, #{records := NFrecords}} -> S4#{records => NFrecords}; + {#{records := PFrecords}, _} -> S4#{records => PFrecords}; + {_, _} -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_dns_records_request/3}). +merge_msg_list_dns_records_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_list_dns_records_response/3}). +merge_msg_list_dns_records_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{dns_records := PFdns_records}, #{dns_records := NFdns_records}} -> S1#{dns_records => 'erlang_++'(PFdns_records, NFdns_records, TrUserData)}; + {_, #{dns_records := NFdns_records}} -> S1#{dns_records => NFdns_records}; + {#{dns_records := PFdns_records}, _} -> S1#{dns_records => PFdns_records}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_dns_record_request/3}). +merge_msg_put_dns_record_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{dns_record := PFdns_record}, #{dns_record := NFdns_record}} -> S1#{dns_record => merge_msg_dns_record(PFdns_record, NFdns_record, TrUserData)}; + {_, #{dns_record := NFdns_record}} -> S1#{dns_record => NFdns_record}; + {#{dns_record := PFdns_record}, _} -> S1#{dns_record => PFdns_record}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_route_table/3}). +merge_msg_route_table(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; + {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S2#{id => NFid}; + {#{id := PFid}, _} -> S2#{id => PFid}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{name := NFname}} -> S3#{name => NFname}; + {#{name := PFname}, _} -> S3#{name => PFname}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_route_table_identifier/3}). +merge_msg_route_table_identifier(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_route_tables_request/3}). +merge_msg_list_route_tables_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; + {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_route_tables_response/3}). +merge_msg_list_route_tables_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route_tables := PFroute_tables}, #{route_tables := NFroute_tables}} -> S1#{route_tables => 'erlang_++'(PFroute_tables, NFroute_tables, TrUserData)}; + {_, #{route_tables := NFroute_tables}} -> S1#{route_tables => NFroute_tables}; + {#{route_tables := PFroute_tables}, _} -> S1#{route_tables => PFroute_tables}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_route_table_request/3}). +merge_msg_create_route_table_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route_table := PFroute_table}, #{route_table := NFroute_table}} -> S1#{route_table => merge_msg_route_table(PFroute_table, NFroute_table, TrUserData)}; + {_, #{route_table := NFroute_table}} -> S1#{route_table => NFroute_table}; + {#{route_table := PFroute_table}, _} -> S1#{route_table => PFroute_table}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_route_identifier/3}). +merge_msg_route_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; + {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_route/3}). +merge_msg_route(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; + {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; + _ -> S2 + end, + case {PMsg, NMsg} of + {#{gateways := PFgateways}, #{gateways := NFgateways}} -> S3#{gateways => 'erlang_++'(PFgateways, NFgateways, TrUserData)}; + {_, #{gateways := NFgateways}} -> S3#{gateways => NFgateways}; + {#{gateways := PFgateways}, _} -> S3#{gateways => PFgateways}; + {_, _} -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_routes_request/3}). +merge_msg_list_routes_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_routes_response/3}). +merge_msg_list_routes_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{routes := PFroutes}, #{routes := NFroutes}} -> S1#{routes => 'erlang_++'(PFroutes, NFroutes, TrUserData)}; + {_, #{routes := NFroutes}} -> S1#{routes => NFroutes}; + {#{routes := PFroutes}, _} -> S1#{routes => PFroutes}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_route_request/3}). +merge_msg_put_route_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route := PFroute}, #{route := NFroute}} -> S1#{route => merge_msg_route(PFroute, NFroute, TrUserData)}; + {_, #{route := NFroute}} -> S1#{route => NFroute}; + {#{route := PFroute}, _} -> S1#{route => PFroute}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_sync_request/3}). +merge_msg_sync_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_timestamp/3}). +merge_msg_timestamp(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; + {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; + {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; + _ -> S2 + end. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + sync_routes_request -> v_msg_sync_routes_request(Msg, [MsgName], TrUserData); + start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); + stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); + get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); + domain -> v_msg_domain(Msg, [MsgName], TrUserData); + list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); + list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); + create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); + delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); + download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); + image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); + get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); + network -> v_msg_network(Msg, [MsgName], TrUserData); + list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); + list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); + create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); + delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); + get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); + volume -> v_msg_volume(Msg, [MsgName], TrUserData); + list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); + list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); + create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); + update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); + delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); + volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); + volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); + list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); + list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); + port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); + port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); + list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); + list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); + put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); + dns_record_identifier -> v_msg_dns_record_identifier(Msg, [MsgName], TrUserData); + dns_record -> v_msg_dns_record(Msg, [MsgName], TrUserData); + list_dns_records_request -> v_msg_list_dns_records_request(Msg, [MsgName], TrUserData); + list_dns_records_response -> v_msg_list_dns_records_response(Msg, [MsgName], TrUserData); + put_dns_record_request -> v_msg_put_dns_record_request(Msg, [MsgName], TrUserData); + route_table -> v_msg_route_table(Msg, [MsgName], TrUserData); + route_table_identifier -> v_msg_route_table_identifier(Msg, [MsgName], TrUserData); + list_route_tables_request -> v_msg_list_route_tables_request(Msg, [MsgName], TrUserData); + list_route_tables_response -> v_msg_list_route_tables_response(Msg, [MsgName], TrUserData); + create_route_table_request -> v_msg_create_route_table_request(Msg, [MsgName], TrUserData); + route_identifier -> v_msg_route_identifier(Msg, [MsgName], TrUserData); + route -> v_msg_route(Msg, [MsgName], TrUserData); + list_routes_request -> v_msg_list_routes_request(Msg, [MsgName], TrUserData); + list_routes_response -> v_msg_list_routes_response(Msg, [MsgName], TrUserData); + put_route_request -> v_msg_put_route_request(Msg, [MsgName], TrUserData); + sync_request -> v_msg_sync_request(Msg, [MsgName], TrUserData); + timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_msg_sync_routes_request/3}). +-dialyzer({nowarn_function,v_msg_sync_routes_request/3}). +v_msg_sync_routes_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_sync_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_routes_request}, M, Path); +v_msg_sync_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_routes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_start_domain_request/3}). +-dialyzer({nowarn_function,v_msg_start_domain_request/3}). +v_msg_start_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); +v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_stop_domain_request/3}). +-dialyzer({nowarn_function,v_msg_stop_domain_request/3}). +v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (force) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); +v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_domain_request/3}). +-dialyzer({nowarn_function,v_msg_get_domain_request/3}). +v_msg_get_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); +v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_domain/3}). +-dialyzer({nowarn_function,v_msg_domain/3}). +v_msg_domain(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); + _ -> ok + end, + case M of + #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); + _ -> ok + end, + case M of + #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); + _ -> ok + end, + case M of + #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); + _ -> ok + end, + case M of + #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); + _ -> ok + end, + case M of + #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); + _ -> ok + end, + case M of + #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); + _ -> ok + end, + case M of + #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); + _ -> ok + end, + case M of + #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); + _ -> ok + end, + case M of + #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (uuid) -> ok; + (name) -> ok; + (vcpu) -> ok; + (memory) -> ok; + (network) -> ok; + (bridge) -> ok; + (state) -> ok; + (private_ip) -> ok; + (ipv6_address) -> ok; + (user_data) -> ok; + (nested_virtualization) -> ok; + (base_image) -> ok; + (created_at) -> ok; + (os_type) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); +v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_request/3}). +-dialyzer({nowarn_function,v_msg_list_domains_request/3}). +v_msg_list_domains_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); +v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_response/3}). +-dialyzer({nowarn_function,v_msg_list_domains_response/3}). +v_msg_list_domains_response(#{} = M, Path, TrUserData) -> + case M of + #{domains := F1} -> + if is_list(F1) -> + _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) + end; + _ -> ok + end, + lists:foreach(fun (domains) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); +v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_domain_request/3}). +-dialyzer({nowarn_function,v_msg_create_domain_request/3}). +v_msg_create_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); +v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_domain_request/3}). +-dialyzer({nowarn_function,v_msg_delete_domain_request/3}). +v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); +v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_download_image_request/3}). +-dialyzer({nowarn_function,v_msg_download_image_request/3}). +v_msg_download_image_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); +v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_image_chunk/3}). +-dialyzer({nowarn_function,v_msg_image_chunk/3}). +v_msg_image_chunk(#{} = M, Path, TrUserData) -> + case M of + #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (bytes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); +v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_network_request/3}). +-dialyzer({nowarn_function,v_msg_get_network_request/3}). +v_msg_get_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); +v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_network/3}). +-dialyzer({nowarn_function,v_msg_network/3}). +v_msg_network(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (name) -> ok; + (cidr) -> ok; + (cidr6) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); +v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_request/3}). +-dialyzer({nowarn_function,v_msg_list_networks_request/3}). +v_msg_list_networks_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); +v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_response/3}). +-dialyzer({nowarn_function,v_msg_list_networks_response/3}). +v_msg_list_networks_response(#{} = M, Path, TrUserData) -> + case M of + #{networks := F1} -> + if is_list(F1) -> + _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) + end; + _ -> ok + end, + lists:foreach(fun (networks) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); +v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_network_request/3}). +-dialyzer({nowarn_function,v_msg_create_network_request/3}). +v_msg_create_network_request(#{} = M, Path, TrUserData) -> + case M of + #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); +v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_network_request/3}). +-dialyzer({nowarn_function,v_msg_delete_network_request/3}). +v_msg_delete_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); +v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_volume_request/3}). +-dialyzer({nowarn_function,v_msg_get_volume_request/3}). +v_msg_get_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); +v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume/3}). +-dialyzer({nowarn_function,v_msg_volume/3}). +v_msg_volume(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (name) -> ok; + (size) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); +v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_request/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_request/3}). +v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); +v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_response/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_response/3}). +v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> + case M of + #{volumes := F1} -> + if is_list(F1) -> + _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) + end; + _ -> ok + end, + lists:foreach(fun (volumes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); +v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_volume_request/3}). +-dialyzer({nowarn_function,v_msg_create_volume_request/3}). +v_msg_create_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (volume) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); +v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_update_volume_request/3}). +-dialyzer({nowarn_function,v_msg_update_volume_request/3}). +v_msg_update_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (volume) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); +v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_volume_request/3}). +-dialyzer({nowarn_function,v_msg_delete_volume_request/3}). +v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); +v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). +v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); +v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment/3}). +v_msg_volume_attachment(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (disk_address) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); +v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). +v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); +v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). +v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> + case M of + #{attachments := F1} -> + if is_list(F1) -> + _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) + end; + _ -> ok + end, + lists:foreach(fun (attachments) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); +v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). +v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (protocol) -> ok; + (source_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); +v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_port_forwarding/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding/3}). +v_msg_port_forwarding(#{} = M, Path, TrUserData) -> + case M of + #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); + _ -> ok + end, + case M of + #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (protocol) -> ok; + (source_port) -> ok; + (target_ip) -> ok; + (target_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); +v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). +v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); +v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). +v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> + case M of + #{port_forwardings := F1} -> + if is_list(F1) -> + _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) + end; + _ -> ok + end, + lists:foreach(fun (port_forwardings) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); +v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). +-dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). +v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> + case M of + #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (port_forwarding) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); +v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_dns_record_identifier/3}). +-dialyzer({nowarn_function,v_msg_dns_record_identifier/3}). +v_msg_dns_record_identifier(#{} = M, Path, TrUserData) -> + case M of + #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (name) -> ok; + (type) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_dns_record_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record_identifier}, M, Path); +v_msg_dns_record_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_dns_record/3}). +-dialyzer({nowarn_function,v_msg_dns_record/3}). +v_msg_dns_record(#{} = M, Path, TrUserData) -> + case M of + #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); + _ -> ok + end, + case M of + #{ttl := F3} -> v_type_uint64(F3, [ttl | Path], TrUserData); + _ -> ok + end, + case M of + #{records := F4} -> + if is_list(F4) -> + _ = [v_type_string(Elem, [records | Path], TrUserData) || Elem <- F4], + ok; + true -> mk_type_error({invalid_list_of, string}, F4, [records | Path]) + end; + _ -> ok + end, + lists:foreach(fun (name) -> ok; + (type) -> ok; + (ttl) -> ok; + (records) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_dns_record(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record}, M, Path); +v_msg_dns_record(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_dns_records_request/3}). +-dialyzer({nowarn_function,v_msg_list_dns_records_request/3}). +v_msg_list_dns_records_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_list_dns_records_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_request}, M, Path); +v_msg_list_dns_records_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_dns_records_response/3}). +-dialyzer({nowarn_function,v_msg_list_dns_records_response/3}). +v_msg_list_dns_records_response(#{} = M, Path, TrUserData) -> + case M of + #{dns_records := F1} -> + if is_list(F1) -> + _ = [v_msg_dns_record(Elem, [dns_records | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, dns_record}}, F1, [dns_records | Path]) + end; + _ -> ok + end, + lists:foreach(fun (dns_records) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_dns_records_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_response}, M, Path); +v_msg_list_dns_records_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_dns_record_request/3}). +-dialyzer({nowarn_function,v_msg_put_dns_record_request/3}). +v_msg_put_dns_record_request(#{} = M, Path, TrUserData) -> + case M of + #{dns_record := F1} -> v_msg_dns_record(F1, [dns_record | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (dns_record) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_dns_record_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_dns_record_request}, M, Path); +v_msg_put_dns_record_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_dns_record_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_route_table/3}). +-dialyzer({nowarn_function,v_msg_route_table/3}). +v_msg_route_table(#{} = M, Path, TrUserData) -> + case M of + #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); + _ -> ok + end, + case M of + #{id := F2} -> v_type_uint32(F2, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network_name) -> ok; + (id) -> ok; + (name) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_table(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table}, M, Path); +v_msg_route_table(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table}, X, Path). + +-compile({nowarn_unused_function,v_msg_route_table_identifier/3}). +-dialyzer({nowarn_function,v_msg_route_table_identifier/3}). +v_msg_route_table_identifier(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_uint32(F1, [id | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_table_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table_identifier}, M, Path); +v_msg_route_table_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_route_tables_request/3}). +-dialyzer({nowarn_function,v_msg_list_route_tables_request/3}). +v_msg_list_route_tables_request(#{} = M, Path, TrUserData) -> + case M of + #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network_name) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_route_tables_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_request}, M, Path); +v_msg_list_route_tables_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_route_tables_response/3}). +-dialyzer({nowarn_function,v_msg_list_route_tables_response/3}). +v_msg_list_route_tables_response(#{} = M, Path, TrUserData) -> + case M of + #{route_tables := F1} -> + if is_list(F1) -> + _ = [v_msg_route_table(Elem, [route_tables | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, route_table}}, F1, [route_tables | Path]) + end; + _ -> ok + end, + lists:foreach(fun (route_tables) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_route_tables_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_response}, M, Path); +v_msg_list_route_tables_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_route_table_request/3}). +-dialyzer({nowarn_function,v_msg_create_route_table_request/3}). +v_msg_create_route_table_request(#{} = M, Path, TrUserData) -> + case M of + #{route_table := F1} -> v_msg_route_table(F1, [route_table | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_route_table_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_route_table_request}, M, Path); +v_msg_create_route_table_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_route_table_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_route_identifier/3}). +-dialyzer({nowarn_function,v_msg_route_identifier/3}). +v_msg_route_identifier(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + case M of + #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (destination) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_identifier}, M, Path); +v_msg_route_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_route/3}). +-dialyzer({nowarn_function,v_msg_route/3}). +v_msg_route(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + case M of + #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); + _ -> ok + end, + case M of + #{gateways := F3} -> + if is_list(F3) -> + _ = [v_type_string(Elem, [gateways | Path], TrUserData) || Elem <- F3], + ok; + true -> mk_type_error({invalid_list_of, string}, F3, [gateways | Path]) + end; + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (destination) -> ok; + (gateways) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route}, M, Path); +v_msg_route(X, Path, _TrUserData) -> mk_type_error({expected_msg, route}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_routes_request/3}). +-dialyzer({nowarn_function,v_msg_list_routes_request/3}). +v_msg_list_routes_request(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_request}, M, Path); +v_msg_list_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_routes_response/3}). +-dialyzer({nowarn_function,v_msg_list_routes_response/3}). +v_msg_list_routes_response(#{} = M, Path, TrUserData) -> + case M of + #{routes := F1} -> + if is_list(F1) -> + _ = [v_msg_route(Elem, [routes | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, route}}, F1, [routes | Path]) + end; + _ -> ok + end, + lists:foreach(fun (routes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_routes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_response}, M, Path); +v_msg_list_routes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_route_request/3}). +-dialyzer({nowarn_function,v_msg_put_route_request/3}). +v_msg_put_route_request(#{} = M, Path, TrUserData) -> + case M of + #{route := F1} -> v_msg_route(F1, [route | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_route_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_route_request}, M, Path); +v_msg_put_route_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_route_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_sync_request/3}). +-dialyzer({nowarn_function,v_msg_sync_request/3}). +v_msg_sync_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_sync_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_request}, M, Path); +v_msg_sync_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_timestamp/3}). +-dialyzer({nowarn_function,v_msg_timestamp/3}). +v_msg_timestamp(#{} = M, Path, TrUserData) -> + case M of + #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); + _ -> ok + end, + case M of + #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (seconds) -> ok; + (nanos) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); +v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). + +-compile({nowarn_unused_function,v_type_int32/3}). +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); +v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_int64/3}). +-dialyzer({nowarn_function,v_type_int64/3}). +v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); +v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_uint32/3}). +-dialyzer({nowarn_function,v_type_uint32/3}). +v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; +v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); +v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_uint64/3}). +-dialyzer({nowarn_function,v_type_uint64/3}). +v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; +v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); +v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_bool/3}). +-dialyzer({nowarn_function,v_type_bool/3}). +v_type_bool(false, _Path, _TrUserData) -> ok; +v_type_bool(true, _Path, _TrUserData) -> ok; +v_type_bool(0, _Path, _TrUserData) -> ok; +v_type_bool(1, _Path, _TrUserData) -> ok; +v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,v_type_bytes/3}). +-dialyzer({nowarn_function,v_type_bytes/3}). +v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; +v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, empty}, []}, + {{msg, sync_routes_request}, []}, + {{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, stop_domain_request}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, + {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, domain}, + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, + {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, + {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, network}, + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, + {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume}, + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, + {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, + {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, + {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment_identifier}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, + {{msg, port_forwarding_identifier}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, + {{msg, port_forwarding}, + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, + {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, dns_record_identifier}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, dns_record}, + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, + #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]}, + {{msg, list_dns_records_request}, []}, + {{msg, list_dns_records_response}, [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]}, + {{msg, put_dns_record_request}, [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]}, + {{msg, route_table}, + [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, route_table_identifier}, [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_route_tables_request}, [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_route_tables_response}, [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]}, + {{msg, create_route_table_request}, [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]}, + {{msg, route_identifier}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, route}, + [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, + #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]}, + {{msg, list_routes_request}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_routes_response}, [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]}, + {{msg, put_route_request}, [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]}, + {{msg, sync_request}, []}, + {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. + + +get_msg_names() -> + [empty, + sync_routes_request, + start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + port_forwarding_identifier, + port_forwarding, + list_port_forwardings_request, + list_port_forwardings_response, + put_port_forwarding_request, + dns_record_identifier, + dns_record, + list_dns_records_request, + list_dns_records_response, + put_dns_record_request, + route_table, + route_table_identifier, + list_route_tables_request, + list_route_tables_response, + create_route_table_request, + route_identifier, + route, + list_routes_request, + list_routes_response, + put_route_request, + sync_request, + timestamp]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> + [empty, + sync_routes_request, + start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + port_forwarding_identifier, + port_forwarding, + list_port_forwardings_request, + list_port_forwardings_response, + put_port_forwarding_request, + dns_record_identifier, + dns_record, + list_dns_records_request, + list_dns_records_response, + put_dns_record_request, + route_table, + route_table_identifier, + list_route_tables_request, + list_route_tables_response, + create_route_table_request, + route_identifier, + route, + list_routes_request, + list_routes_response, + put_route_request, + sync_request, + timestamp]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(empty) -> []; +find_msg_def(sync_routes_request) -> []; +find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(stop_domain_request) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; +find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(domain) -> + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; +find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; +find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(network) -> + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; +find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume) -> + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; +find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; +find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment_identifier) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; +find_msg_def(port_forwarding_identifier) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(port_forwarding) -> + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; +find_msg_def(put_port_forwarding_request) -> + [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(dns_record_identifier) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(dns_record) -> + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, + #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]; +find_msg_def(list_dns_records_request) -> []; +find_msg_def(list_dns_records_response) -> [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]; +find_msg_def(put_dns_record_request) -> [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]; +find_msg_def(route_table) -> + [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(route_table_identifier) -> [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_route_tables_request) -> [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_route_tables_response) -> [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]; +find_msg_def(create_route_table_request) -> [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]; +find_msg_def(route_identifier) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(route) -> + [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, + #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]; +find_msg_def(list_routes_request) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_routes_response) -> [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]; +find_msg_def(put_route_request) -> [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]; +find_msg_def(sync_request) -> []; +find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['ControllerService', 'DaemonService', 'DomainService', 'VolumeService', 'PortForwardingService', 'DNS', 'RouteService']. + + +get_service_def('ControllerService') -> + {{service, 'ControllerService'}, + [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('DaemonService') -> + {{service, 'DaemonService'}, + [#{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('DomainService') -> + {{service, 'DomainService'}, + [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('VolumeService') -> + {{service, 'VolumeService'}, + [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('PortForwardingService') -> + {{service, 'PortForwardingService'}, + [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('DNS') -> + {{service, 'DNS'}, + [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('RouteService') -> + {{service, 'RouteService'}, + [#{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('ControllerService') -> + ['GetDNSRecord', + 'ListDNSRecords', + 'PutDNSRecord', + 'DeleteDNSRecord', + 'GetNetwork', + 'ListNetworks', + 'CreateNetwork', + 'DeleteNetwork', + 'StartDomain', + 'StopDomain', + 'GetDomain', + 'ListDomains', + 'CreateDomain', + 'DeleteDomain', + 'DownloadImage', + 'GetVolume', + 'ListVolumes', + 'CreateVolume', + 'UpdateVolume', + 'DeleteVolume', + 'ListVolumeAttachments', + 'GetVolumeAttachment', + 'AttachVolume', + 'DetachVolume', + 'GetPortForwarding', + 'ListPortForwardings', + 'PutPortForwarding', + 'DeletePortForwarding', + 'GetRouteTable', + 'ListRouteTables', + 'CreateRouteTable', + 'DeleteRouteTable', + 'GetRoute', + 'ListRoutes', + 'PutRoute', + 'DeleteRoute', + 'SyncRoutes']; +get_rpc_names('DaemonService') -> + ['GetNetwork', + 'ListNetworks', + 'CreateNetwork', + 'DeleteNetwork', + 'StartDomain', + 'StopDomain', + 'GetDomain', + 'ListDomains', + 'CreateDomain', + 'DeleteDomain', + 'DownloadImage', + 'GetVolume', + 'ListVolumes', + 'CreateVolume', + 'UpdateVolume', + 'DeleteVolume', + 'ListVolumeAttachments', + 'GetVolumeAttachment', + 'AttachVolume', + 'DetachVolume', + 'GetPortForwarding', + 'ListPortForwardings', + 'PutPortForwarding', + 'DeletePortForwarding', + 'SyncRoutes']; +get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; +get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; +get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; +get_rpc_names('DNS') -> ['GetDNSRecord', 'ListDNSRecords', 'PutDNSRecord', 'DeleteDNSRecord']; +get_rpc_names('RouteService') -> ['GetRouteTable', 'ListRouteTables', 'CreateRouteTable', 'DeleteRouteTable', 'GetRoute', 'ListRoutes', 'PutRoute', 'DeleteRoute', 'Sync']; +get_rpc_names(_) -> error. + + +find_rpc_def('ControllerService', RpcName) -> find_rpc_def_ControllerService(RpcName); +find_rpc_def('DaemonService', RpcName) -> find_rpc_def_DaemonService(RpcName); +find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); +find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); +find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); +find_rpc_def('DNS', RpcName) -> find_rpc_def_DNS(RpcName); +find_rpc_def('RouteService', RpcName) -> find_rpc_def_RouteService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_ControllerService('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_ControllerService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_ControllerService(_) -> error. + +find_rpc_def_DaemonService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_DaemonService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService(_) -> error. + +find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService(_) -> error. + +find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService(_) -> error. + +find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService(_) -> error. + +find_rpc_def_DNS('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS(_) -> error. + +find_rpc_def_RouteService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('Sync') -> #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"ControllerService">>) -> 'ControllerService'; +fqbin_to_service_name(<<"DaemonService">>) -> 'DaemonService'; +fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; +fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; +fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; +fqbin_to_service_name(<<"DNS">>) -> 'DNS'; +fqbin_to_service_name(<<"RouteService">>) -> 'RouteService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('ControllerService') -> <<"ControllerService">>; +service_name_to_fqbin('DaemonService') -> <<"DaemonService">>; +service_name_to_fqbin('DomainService') -> <<"DomainService">>; +service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; +service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; +service_name_to_fqbin('DNS') -> <<"DNS">>; +service_name_to_fqbin('RouteService') -> <<"RouteService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetDNSRecord">>) -> {'ControllerService', 'GetDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListDNSRecords">>) -> {'ControllerService', 'ListDNSRecords'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutDNSRecord">>) -> {'ControllerService', 'PutDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteDNSRecord">>) -> {'ControllerService', 'DeleteDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetNetwork">>) -> {'ControllerService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListNetworks">>) -> {'ControllerService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateNetwork">>) -> {'ControllerService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteNetwork">>) -> {'ControllerService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"StartDomain">>) -> {'ControllerService', 'StartDomain'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"StopDomain">>) -> {'ControllerService', 'StopDomain'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetDomain">>) -> {'ControllerService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListDomains">>) -> {'ControllerService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateDomain">>) -> {'ControllerService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteDomain">>) -> {'ControllerService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DownloadImage">>) -> {'ControllerService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetVolume">>) -> {'ControllerService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListVolumes">>) -> {'ControllerService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateVolume">>) -> {'ControllerService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"UpdateVolume">>) -> {'ControllerService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteVolume">>) -> {'ControllerService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListVolumeAttachments">>) -> {'ControllerService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetVolumeAttachment">>) -> {'ControllerService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"AttachVolume">>) -> {'ControllerService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DetachVolume">>) -> {'ControllerService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetPortForwarding">>) -> {'ControllerService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListPortForwardings">>) -> {'ControllerService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutPortForwarding">>) -> {'ControllerService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeletePortForwarding">>) -> {'ControllerService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetRouteTable">>) -> {'ControllerService', 'GetRouteTable'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListRouteTables">>) -> {'ControllerService', 'ListRouteTables'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateRouteTable">>) -> {'ControllerService', 'CreateRouteTable'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteRouteTable">>) -> {'ControllerService', 'DeleteRouteTable'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetRoute">>) -> {'ControllerService', 'GetRoute'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListRoutes">>) -> {'ControllerService', 'ListRoutes'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutRoute">>) -> {'ControllerService', 'PutRoute'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteRoute">>) -> {'ControllerService', 'DeleteRoute'}; +fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"SyncRoutes">>) -> {'ControllerService', 'SyncRoutes'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetNetwork">>) -> {'DaemonService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListNetworks">>) -> {'DaemonService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateNetwork">>) -> {'DaemonService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteNetwork">>) -> {'DaemonService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StartDomain">>) -> {'DaemonService', 'StartDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StopDomain">>) -> {'DaemonService', 'StopDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetDomain">>) -> {'DaemonService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListDomains">>) -> {'DaemonService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateDomain">>) -> {'DaemonService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteDomain">>) -> {'DaemonService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DownloadImage">>) -> {'DaemonService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolume">>) -> {'DaemonService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumes">>) -> {'DaemonService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateVolume">>) -> {'DaemonService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"UpdateVolume">>) -> {'DaemonService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteVolume">>) -> {'DaemonService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumeAttachments">>) -> {'DaemonService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolumeAttachment">>) -> {'DaemonService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"AttachVolume">>) -> {'DaemonService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DetachVolume">>) -> {'DaemonService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetPortForwarding">>) -> {'DaemonService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListPortForwardings">>) -> {'DaemonService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"PutPortForwarding">>) -> {'DaemonService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeletePortForwarding">>) -> {'DaemonService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"SyncRoutes">>) -> {'DaemonService', 'SyncRoutes'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"GetDNSRecord">>) -> {'DNS', 'GetDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"ListDNSRecords">>) -> {'DNS', 'ListDNSRecords'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"PutDNSRecord">>) -> {'DNS', 'PutDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"DeleteDNSRecord">>) -> {'DNS', 'DeleteDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRouteTable">>) -> {'RouteService', 'GetRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRouteTables">>) -> {'RouteService', 'ListRouteTables'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"CreateRouteTable">>) -> {'RouteService', 'CreateRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRouteTable">>) -> {'RouteService', 'DeleteRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRoute">>) -> {'RouteService', 'GetRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRoutes">>) -> {'RouteService', 'ListRoutes'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"PutRoute">>) -> {'RouteService', 'PutRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRoute">>) -> {'RouteService', 'DeleteRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"Sync">>) -> {'RouteService', 'Sync'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('ControllerService', 'GetDNSRecord') -> {<<"ControllerService">>, <<"GetDNSRecord">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListDNSRecords') -> {<<"ControllerService">>, <<"ListDNSRecords">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'PutDNSRecord') -> {<<"ControllerService">>, <<"PutDNSRecord">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteDNSRecord') -> {<<"ControllerService">>, <<"DeleteDNSRecord">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetNetwork') -> {<<"ControllerService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListNetworks') -> {<<"ControllerService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'CreateNetwork') -> {<<"ControllerService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteNetwork') -> {<<"ControllerService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'StartDomain') -> {<<"ControllerService">>, <<"StartDomain">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'StopDomain') -> {<<"ControllerService">>, <<"StopDomain">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetDomain') -> {<<"ControllerService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListDomains') -> {<<"ControllerService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'CreateDomain') -> {<<"ControllerService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteDomain') -> {<<"ControllerService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DownloadImage') -> {<<"ControllerService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetVolume') -> {<<"ControllerService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListVolumes') -> {<<"ControllerService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'CreateVolume') -> {<<"ControllerService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'UpdateVolume') -> {<<"ControllerService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteVolume') -> {<<"ControllerService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListVolumeAttachments') -> {<<"ControllerService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetVolumeAttachment') -> {<<"ControllerService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'AttachVolume') -> {<<"ControllerService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DetachVolume') -> {<<"ControllerService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetPortForwarding') -> {<<"ControllerService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListPortForwardings') -> {<<"ControllerService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'PutPortForwarding') -> {<<"ControllerService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeletePortForwarding') -> {<<"ControllerService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetRouteTable') -> {<<"ControllerService">>, <<"GetRouteTable">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListRouteTables') -> {<<"ControllerService">>, <<"ListRouteTables">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'CreateRouteTable') -> {<<"ControllerService">>, <<"CreateRouteTable">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteRouteTable') -> {<<"ControllerService">>, <<"DeleteRouteTable">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'GetRoute') -> {<<"ControllerService">>, <<"GetRoute">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'ListRoutes') -> {<<"ControllerService">>, <<"ListRoutes">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'PutRoute') -> {<<"ControllerService">>, <<"PutRoute">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'DeleteRoute') -> {<<"ControllerService">>, <<"DeleteRoute">>}; +service_and_rpc_name_to_fqbins('ControllerService', 'SyncRoutes') -> {<<"ControllerService">>, <<"SyncRoutes">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetNetwork') -> {<<"DaemonService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListNetworks') -> {<<"DaemonService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateNetwork') -> {<<"DaemonService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteNetwork') -> {<<"DaemonService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'StartDomain') -> {<<"DaemonService">>, <<"StartDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'StopDomain') -> {<<"DaemonService">>, <<"StopDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetDomain') -> {<<"DaemonService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListDomains') -> {<<"DaemonService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateDomain') -> {<<"DaemonService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteDomain') -> {<<"DaemonService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DownloadImage') -> {<<"DaemonService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetVolume') -> {<<"DaemonService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumes') -> {<<"DaemonService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateVolume') -> {<<"DaemonService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'UpdateVolume') -> {<<"DaemonService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteVolume') -> {<<"DaemonService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumeAttachments') -> {<<"DaemonService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetVolumeAttachment') -> {<<"DaemonService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'AttachVolume') -> {<<"DaemonService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DetachVolume') -> {<<"DaemonService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetPortForwarding') -> {<<"DaemonService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListPortForwardings') -> {<<"DaemonService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'PutPortForwarding') -> {<<"DaemonService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeletePortForwarding') -> {<<"DaemonService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'SyncRoutes') -> {<<"DaemonService">>, <<"SyncRoutes">>}; +service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins('DNS', 'GetDNSRecord') -> {<<"DNS">>, <<"GetDNSRecord">>}; +service_and_rpc_name_to_fqbins('DNS', 'ListDNSRecords') -> {<<"DNS">>, <<"ListDNSRecords">>}; +service_and_rpc_name_to_fqbins('DNS', 'PutDNSRecord') -> {<<"DNS">>, <<"PutDNSRecord">>}; +service_and_rpc_name_to_fqbins('DNS', 'DeleteDNSRecord') -> {<<"DNS">>, <<"DeleteDNSRecord">>}; +service_and_rpc_name_to_fqbins('RouteService', 'GetRouteTable') -> {<<"RouteService">>, <<"GetRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'ListRouteTables') -> {<<"RouteService">>, <<"ListRouteTables">>}; +service_and_rpc_name_to_fqbins('RouteService', 'CreateRouteTable') -> {<<"RouteService">>, <<"CreateRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'DeleteRouteTable') -> {<<"RouteService">>, <<"DeleteRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'GetRoute') -> {<<"RouteService">>, <<"GetRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'ListRoutes') -> {<<"RouteService">>, <<"ListRoutes">>}; +service_and_rpc_name_to_fqbins('RouteService', 'PutRoute') -> {<<"RouteService">>, <<"PutRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'DeleteRoute') -> {<<"RouteService">>, <<"DeleteRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'Sync') -> {<<"RouteService">>, <<"Sync">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(<<"SyncRoutesRequest">>) -> sync_routes_request; +fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; +fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; +fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; +fqbin_to_msg_name(<<"Domain">>) -> domain; +fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; +fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; +fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; +fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; +fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; +fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; +fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; +fqbin_to_msg_name(<<"Network">>) -> network; +fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; +fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; +fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; +fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; +fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; +fqbin_to_msg_name(<<"Volume">>) -> volume; +fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; +fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; +fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; +fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; +fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; +fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; +fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; +fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; +fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; +fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; +fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; +fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; +fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; +fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; +fqbin_to_msg_name(<<"DNSRecordIdentifier">>) -> dns_record_identifier; +fqbin_to_msg_name(<<"DNSRecord">>) -> dns_record; +fqbin_to_msg_name(<<"ListDNSRecordsRequest">>) -> list_dns_records_request; +fqbin_to_msg_name(<<"ListDNSRecordsResponse">>) -> list_dns_records_response; +fqbin_to_msg_name(<<"PutDNSRecordRequest">>) -> put_dns_record_request; +fqbin_to_msg_name(<<"RouteTable">>) -> route_table; +fqbin_to_msg_name(<<"RouteTableIdentifier">>) -> route_table_identifier; +fqbin_to_msg_name(<<"ListRouteTablesRequest">>) -> list_route_tables_request; +fqbin_to_msg_name(<<"ListRouteTablesResponse">>) -> list_route_tables_response; +fqbin_to_msg_name(<<"CreateRouteTableRequest">>) -> create_route_table_request; +fqbin_to_msg_name(<<"RouteIdentifier">>) -> route_identifier; +fqbin_to_msg_name(<<"Route">>) -> route; +fqbin_to_msg_name(<<"ListRoutesRequest">>) -> list_routes_request; +fqbin_to_msg_name(<<"ListRoutesResponse">>) -> list_routes_response; +fqbin_to_msg_name(<<"PutRouteRequest">>) -> put_route_request; +fqbin_to_msg_name(<<"SyncRequest">>) -> sync_request; +fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(sync_routes_request) -> <<"SyncRoutesRequest">>; +msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; +msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; +msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; +msg_name_to_fqbin(domain) -> <<"Domain">>; +msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; +msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; +msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; +msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; +msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; +msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; +msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; +msg_name_to_fqbin(network) -> <<"Network">>; +msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; +msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; +msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; +msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; +msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; +msg_name_to_fqbin(volume) -> <<"Volume">>; +msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; +msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; +msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; +msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; +msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; +msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; +msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; +msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; +msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; +msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; +msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; +msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; +msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; +msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; +msg_name_to_fqbin(dns_record_identifier) -> <<"DNSRecordIdentifier">>; +msg_name_to_fqbin(dns_record) -> <<"DNSRecord">>; +msg_name_to_fqbin(list_dns_records_request) -> <<"ListDNSRecordsRequest">>; +msg_name_to_fqbin(list_dns_records_response) -> <<"ListDNSRecordsResponse">>; +msg_name_to_fqbin(put_dns_record_request) -> <<"PutDNSRecordRequest">>; +msg_name_to_fqbin(route_table) -> <<"RouteTable">>; +msg_name_to_fqbin(route_table_identifier) -> <<"RouteTableIdentifier">>; +msg_name_to_fqbin(list_route_tables_request) -> <<"ListRouteTablesRequest">>; +msg_name_to_fqbin(list_route_tables_response) -> <<"ListRouteTablesResponse">>; +msg_name_to_fqbin(create_route_table_request) -> <<"CreateRouteTableRequest">>; +msg_name_to_fqbin(route_identifier) -> <<"RouteIdentifier">>; +msg_name_to_fqbin(route) -> <<"Route">>; +msg_name_to_fqbin(list_routes_request) -> <<"ListRoutesRequest">>; +msg_name_to_fqbin(list_routes_response) -> <<"ListRoutesResponse">>; +msg_name_to_fqbin(put_route_request) -> <<"PutRouteRequest">>; +msg_name_to_fqbin(sync_request) -> <<"SyncRequest">>; +msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "controller.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["controller.proto", "empty.proto", "daemon.proto", "domain.proto", "volume.proto", "port_forwarding.proto", "dns.proto", "route.proto", "timestamp.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["controller", "empty", "daemon", "domain", "volume", "port_forwarding", "dns", "route", "timestamp"]. + + +get_msg_containment("controller") -> []; +get_msg_containment("empty") -> [empty]; +get_msg_containment("daemon") -> [sync_routes_request]; +get_msg_containment("domain") -> + [create_domain_request, + create_network_request, + delete_domain_request, + delete_network_request, + domain, + download_image_request, + get_domain_request, + get_network_request, + image_chunk, + list_domains_request, + list_domains_response, + list_networks_request, + list_networks_response, + network, + start_domain_request, + stop_domain_request]; +get_msg_containment("volume") -> + [create_volume_request, + delete_volume_request, + get_volume_request, + list_volume_attachments_request, + list_volume_attachments_response, + list_volumes_request, + list_volumes_response, + update_volume_request, + volume, + volume_attachment, + volume_attachment_identifier]; +get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; +get_msg_containment("dns") -> [dns_record, dns_record_identifier, list_dns_records_request, list_dns_records_response, put_dns_record_request]; +get_msg_containment("route") -> + [create_route_table_request, list_route_tables_request, list_route_tables_response, list_routes_request, list_routes_response, put_route_request, route, route_identifier, route_table, route_table_identifier, sync_request]; +get_msg_containment("timestamp") -> [timestamp]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("controller") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment("daemon") -> undefined; +get_pkg_containment("domain") -> undefined; +get_pkg_containment("volume") -> undefined; +get_pkg_containment("port_forwarding") -> undefined; +get_pkg_containment("dns") -> undefined; +get_pkg_containment("route") -> undefined; +get_pkg_containment("timestamp") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("controller") -> ['ControllerService']; +get_service_containment("empty") -> []; +get_service_containment("daemon") -> ['DaemonService']; +get_service_containment("domain") -> ['DomainService']; +get_service_containment("volume") -> ['VolumeService']; +get_service_containment("port_forwarding") -> ['PortForwardingService']; +get_service_containment("dns") -> ['DNS']; +get_service_containment("route") -> ['RouteService']; +get_service_containment("timestamp") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("controller") -> + [{'ControllerService', 'GetDNSRecord'}, + {'ControllerService', 'ListDNSRecords'}, + {'ControllerService', 'PutDNSRecord'}, + {'ControllerService', 'DeleteDNSRecord'}, + {'ControllerService', 'GetNetwork'}, + {'ControllerService', 'ListNetworks'}, + {'ControllerService', 'CreateNetwork'}, + {'ControllerService', 'DeleteNetwork'}, + {'ControllerService', 'StartDomain'}, + {'ControllerService', 'StopDomain'}, + {'ControllerService', 'GetDomain'}, + {'ControllerService', 'ListDomains'}, + {'ControllerService', 'CreateDomain'}, + {'ControllerService', 'DeleteDomain'}, + {'ControllerService', 'DownloadImage'}, + {'ControllerService', 'GetVolume'}, + {'ControllerService', 'ListVolumes'}, + {'ControllerService', 'CreateVolume'}, + {'ControllerService', 'UpdateVolume'}, + {'ControllerService', 'DeleteVolume'}, + {'ControllerService', 'ListVolumeAttachments'}, + {'ControllerService', 'GetVolumeAttachment'}, + {'ControllerService', 'AttachVolume'}, + {'ControllerService', 'DetachVolume'}, + {'ControllerService', 'GetPortForwarding'}, + {'ControllerService', 'ListPortForwardings'}, + {'ControllerService', 'PutPortForwarding'}, + {'ControllerService', 'DeletePortForwarding'}, + {'ControllerService', 'GetRouteTable'}, + {'ControllerService', 'ListRouteTables'}, + {'ControllerService', 'CreateRouteTable'}, + {'ControllerService', 'DeleteRouteTable'}, + {'ControllerService', 'GetRoute'}, + {'ControllerService', 'ListRoutes'}, + {'ControllerService', 'PutRoute'}, + {'ControllerService', 'DeleteRoute'}, + {'ControllerService', 'SyncRoutes'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment("daemon") -> + [{'DaemonService', 'GetNetwork'}, + {'DaemonService', 'ListNetworks'}, + {'DaemonService', 'CreateNetwork'}, + {'DaemonService', 'DeleteNetwork'}, + {'DaemonService', 'StartDomain'}, + {'DaemonService', 'StopDomain'}, + {'DaemonService', 'GetDomain'}, + {'DaemonService', 'ListDomains'}, + {'DaemonService', 'CreateDomain'}, + {'DaemonService', 'DeleteDomain'}, + {'DaemonService', 'DownloadImage'}, + {'DaemonService', 'GetVolume'}, + {'DaemonService', 'ListVolumes'}, + {'DaemonService', 'CreateVolume'}, + {'DaemonService', 'UpdateVolume'}, + {'DaemonService', 'DeleteVolume'}, + {'DaemonService', 'ListVolumeAttachments'}, + {'DaemonService', 'GetVolumeAttachment'}, + {'DaemonService', 'AttachVolume'}, + {'DaemonService', 'DetachVolume'}, + {'DaemonService', 'GetPortForwarding'}, + {'DaemonService', 'ListPortForwardings'}, + {'DaemonService', 'PutPortForwarding'}, + {'DaemonService', 'DeletePortForwarding'}, + {'DaemonService', 'SyncRoutes'}]; +get_rpc_containment("domain") -> + [{'DomainService', 'GetDomain'}, + {'DomainService', 'ListDomains'}, + {'DomainService', 'CreateDomain'}, + {'DomainService', 'DeleteDomain'}, + {'DomainService', 'DownloadImage'}, + {'DomainService', 'GetNetwork'}, + {'DomainService', 'ListNetworks'}, + {'DomainService', 'CreateNetwork'}, + {'DomainService', 'DeleteNetwork'}]; +get_rpc_containment("volume") -> + [{'VolumeService', 'GetVolume'}, + {'VolumeService', 'ListVolumes'}, + {'VolumeService', 'CreateVolume'}, + {'VolumeService', 'UpdateVolume'}, + {'VolumeService', 'DeleteVolume'}, + {'VolumeService', 'ListVolumeAttachments'}, + {'VolumeService', 'GetVolumeAttachment'}, + {'VolumeService', 'AttachVolume'}, + {'VolumeService', 'DetachVolume'}]; +get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; +get_rpc_containment("dns") -> [{'DNS', 'GetDNSRecord'}, {'DNS', 'ListDNSRecords'}, {'DNS', 'PutDNSRecord'}, {'DNS', 'DeleteDNSRecord'}]; +get_rpc_containment("route") -> + [{'RouteService', 'GetRouteTable'}, + {'RouteService', 'ListRouteTables'}, + {'RouteService', 'CreateRouteTable'}, + {'RouteService', 'DeleteRouteTable'}, + {'RouteService', 'GetRoute'}, + {'RouteService', 'ListRoutes'}, + {'RouteService', 'PutRoute'}, + {'RouteService', 'DeleteRoute'}, + {'RouteService', 'Sync'}]; +get_rpc_containment("timestamp") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("controller") -> []; +get_enum_containment("empty") -> []; +get_enum_containment("daemon") -> []; +get_enum_containment("domain") -> []; +get_enum_containment("volume") -> []; +get_enum_containment("port_forwarding") -> []; +get_enum_containment("dns") -> []; +get_enum_containment("route") -> []; +get_enum_containment("timestamp") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; +get_proto_by_msg_name_as_fqbin(<<"RouteTableIdentifier">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"RouteIdentifier">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"DNSRecordIdentifier">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"SyncRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"PutRouteRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRoutesRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"CreateRouteTableRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"PutDNSRecordRequest">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsRequest">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"DNSRecord">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"SyncRoutesRequest">>) -> "daemon"; +get_proto_by_msg_name_as_fqbin(<<"RouteTable">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"Route">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRoutesResponse">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesResponse">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsResponse">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"DNS">>) -> "dns"; +get_proto_by_service_name_as_fqbin(<<"RouteService">>) -> "route"; +get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; +get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; +get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; +get_proto_by_service_name_as_fqbin(<<"DaemonService">>) -> "daemon"; +get_proto_by_service_name_as_fqbin(<<"ControllerService">>) -> "controller"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/controller_service_bhvr.erl b/virtuerl/src/pb/controller_service_bhvr.erl new file mode 100644 index 0000000..888c9f9 --- /dev/null +++ b/virtuerl/src/pb/controller_service_bhvr.erl @@ -0,0 +1,157 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service ControllerService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(controller_service_bhvr). + +%% Unary RPC +-callback get_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> + {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_dns_records(ctx:t(), controller_pb:list_dns_records_request()) -> + {ok, controller_pb:list_dns_records_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_dns_record(ctx:t(), controller_pb:put_dns_record_request()) -> + {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_network(ctx:t(), controller_pb:get_network_request()) -> + {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_networks(ctx:t(), controller_pb:list_networks_request()) -> + {ok, controller_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_network(ctx:t(), controller_pb:create_network_request()) -> + {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_network(ctx:t(), controller_pb:delete_network_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback start_domain(ctx:t(), controller_pb:start_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback stop_domain(ctx:t(), controller_pb:stop_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_domain(ctx:t(), controller_pb:get_domain_request()) -> + {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_domains(ctx:t(), controller_pb:list_domains_request()) -> + {ok, controller_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_domain(ctx:t(), controller_pb:create_domain_request()) -> + {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_domain(ctx:t(), controller_pb:delete_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% +-callback download_image(controller_pb:download_image_request(), grpcbox_stream:t()) -> + ok | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request()) -> + {ok, controller_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request()) -> + {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_route_table(ctx:t(), controller_pb:route_table_identifier()) -> + {ok, controller_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_route_tables(ctx:t(), controller_pb:list_route_tables_request()) -> + {ok, controller_pb:list_route_tables_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_route_table(ctx:t(), controller_pb:create_route_table_request()) -> + {ok, controller_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_route_table(ctx:t(), controller_pb:route_table_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_route(ctx:t(), controller_pb:route_identifier()) -> + {ok, controller_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_routes(ctx:t(), controller_pb:list_routes_request()) -> + {ok, controller_pb:list_routes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_route(ctx:t(), controller_pb:put_route_request()) -> + {ok, controller_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_route(ctx:t(), controller_pb:route_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback sync_routes(ctx:t(), controller_pb:sync_routes_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/controller_service_client.erl b/virtuerl/src/pb/controller_service_client.erl new file mode 100644 index 0000000..c7ac599 --- /dev/null +++ b/virtuerl/src/pb/controller_service_client.erl @@ -0,0 +1,691 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service ControllerService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(controller_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'ControllerService'). +-define(PROTO_MODULE, 'controller_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_dns_record(controller_pb:dns_record_identifier()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Input) -> + get_dns_record(ctx:new(), Input, #{}). + +-spec get_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + get_dns_record(Ctx, Input, #{}); +get_dns_record(Input, Options) -> + get_dns_record(ctx:new(), Input, Options). + +-spec get_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetDNSRecord">>, Input, ?DEF(dns_record_identifier, dns_record, <<"DNSRecordIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_dns_records(controller_pb:list_dns_records_request()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Input) -> + list_dns_records(ctx:new(), Input, #{}). + +-spec list_dns_records(ctx:t() | controller_pb:list_dns_records_request(), controller_pb:list_dns_records_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Ctx, Input) when ?is_ctx(Ctx) -> + list_dns_records(Ctx, Input, #{}); +list_dns_records(Input, Options) -> + list_dns_records(ctx:new(), Input, Options). + +-spec list_dns_records(ctx:t(), controller_pb:list_dns_records_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListDNSRecords">>, Input, ?DEF(list_dns_records_request, list_dns_records_response, <<"ListDNSRecordsRequest">>), Options). + +%% @doc Unary RPC +-spec put_dns_record(controller_pb:put_dns_record_request()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Input) -> + put_dns_record(ctx:new(), Input, #{}). + +-spec put_dns_record(ctx:t() | controller_pb:put_dns_record_request(), controller_pb:put_dns_record_request() | grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + put_dns_record(Ctx, Input, #{}); +put_dns_record(Input, Options) -> + put_dns_record(ctx:new(), Input, Options). + +-spec put_dns_record(ctx:t(), controller_pb:put_dns_record_request(), grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/PutDNSRecord">>, Input, ?DEF(put_dns_record_request, dns_record, <<"PutDNSRecordRequest">>), Options). + +%% @doc Unary RPC +-spec delete_dns_record(controller_pb:dns_record_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Input) -> + delete_dns_record(ctx:new(), Input, #{}). + +-spec delete_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + delete_dns_record(Ctx, Input, #{}); +delete_dns_record(Input, Options) -> + delete_dns_record(ctx:new(), Input, Options). + +-spec delete_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteDNSRecord">>, Input, ?DEF(dns_record_identifier, empty, <<"DNSRecordIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_network(controller_pb:get_network_request()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Input) -> + get_network(ctx:new(), Input, #{}). + +-spec get_network(ctx:t() | controller_pb:get_network_request(), controller_pb:get_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input) when ?is_ctx(Ctx) -> + get_network(Ctx, Input, #{}); +get_network(Input, Options) -> + get_network(ctx:new(), Input, Options). + +-spec get_network(ctx:t(), controller_pb:get_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec list_networks(controller_pb:list_networks_request()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Input) -> + list_networks(ctx:new(), Input, #{}). + +-spec list_networks(ctx:t() | controller_pb:list_networks_request(), controller_pb:list_networks_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input) when ?is_ctx(Ctx) -> + list_networks(Ctx, Input, #{}); +list_networks(Input, Options) -> + list_networks(ctx:new(), Input, Options). + +-spec list_networks(ctx:t(), controller_pb:list_networks_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). + +%% @doc Unary RPC +-spec create_network(controller_pb:create_network_request()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Input) -> + create_network(ctx:new(), Input, #{}). + +-spec create_network(ctx:t() | controller_pb:create_network_request(), controller_pb:create_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input) when ?is_ctx(Ctx) -> + create_network(Ctx, Input, #{}); +create_network(Input, Options) -> + create_network(ctx:new(), Input, Options). + +-spec create_network(ctx:t(), controller_pb:create_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec delete_network(controller_pb:delete_network_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Input) -> + delete_network(ctx:new(), Input, #{}). + +-spec delete_network(ctx:t() | controller_pb:delete_network_request(), controller_pb:delete_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input) when ?is_ctx(Ctx) -> + delete_network(Ctx, Input, #{}); +delete_network(Input, Options) -> + delete_network(ctx:new(), Input, Options). + +-spec delete_network(ctx:t(), controller_pb:delete_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec start_domain(controller_pb:start_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Input) -> + start_domain(ctx:new(), Input, #{}). + +-spec start_domain(ctx:t() | controller_pb:start_domain_request(), controller_pb:start_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Ctx, Input) when ?is_ctx(Ctx) -> + start_domain(Ctx, Input, #{}); +start_domain(Input, Options) -> + start_domain(ctx:new(), Input, Options). + +-spec start_domain(ctx:t(), controller_pb:start_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/StartDomain">>, Input, ?DEF(start_domain_request, empty, <<"StartDomainRequest">>), Options). + +%% @doc Unary RPC +-spec stop_domain(controller_pb:stop_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Input) -> + stop_domain(ctx:new(), Input, #{}). + +-spec stop_domain(ctx:t() | controller_pb:stop_domain_request(), controller_pb:stop_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Ctx, Input) when ?is_ctx(Ctx) -> + stop_domain(Ctx, Input, #{}); +stop_domain(Input, Options) -> + stop_domain(ctx:new(), Input, Options). + +-spec stop_domain(ctx:t(), controller_pb:stop_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/StopDomain">>, Input, ?DEF(stop_domain_request, empty, <<"StopDomainRequest">>), Options). + +%% @doc Unary RPC +-spec get_domain(controller_pb:get_domain_request()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Input) -> + get_domain(ctx:new(), Input, #{}). + +-spec get_domain(ctx:t() | controller_pb:get_domain_request(), controller_pb:get_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input) when ?is_ctx(Ctx) -> + get_domain(Ctx, Input, #{}); +get_domain(Input, Options) -> + get_domain(ctx:new(), Input, Options). + +-spec get_domain(ctx:t(), controller_pb:get_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). + +%% @doc Unary RPC +-spec list_domains(controller_pb:list_domains_request()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Input) -> + list_domains(ctx:new(), Input, #{}). + +-spec list_domains(ctx:t() | controller_pb:list_domains_request(), controller_pb:list_domains_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input) when ?is_ctx(Ctx) -> + list_domains(Ctx, Input, #{}); +list_domains(Input, Options) -> + list_domains(ctx:new(), Input, Options). + +-spec list_domains(ctx:t(), controller_pb:list_domains_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). + +%% @doc Unary RPC +-spec create_domain(controller_pb:create_domain_request()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Input) -> + create_domain(ctx:new(), Input, #{}). + +-spec create_domain(ctx:t() | controller_pb:create_domain_request(), controller_pb:create_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input) when ?is_ctx(Ctx) -> + create_domain(Ctx, Input, #{}); +create_domain(Input, Options) -> + create_domain(ctx:new(), Input, Options). + +-spec create_domain(ctx:t(), controller_pb:create_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). + +%% @doc Unary RPC +-spec delete_domain(controller_pb:delete_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Input) -> + delete_domain(ctx:new(), Input, #{}). + +-spec delete_domain(ctx:t() | controller_pb:delete_domain_request(), controller_pb:delete_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> + delete_domain(Ctx, Input, #{}); +delete_domain(Input, Options) -> + delete_domain(ctx:new(), Input, Options). + +-spec delete_domain(ctx:t(), controller_pb:delete_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). + +%% @doc +-spec download_image(controller_pb:download_image_request()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Input) -> + download_image(ctx:new(), Input, #{}). + +-spec download_image(ctx:t() | controller_pb:download_image_request(), controller_pb:download_image_request() | grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input) when ?is_ctx(Ctx) -> + download_image(Ctx, Input, #{}); +download_image(Input, Options) -> + download_image(ctx:new(), Input, Options). + +-spec download_image(ctx:t(), controller_pb:download_image_request(), grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input, Options) -> + grpcbox_client:stream(Ctx, <<"/ControllerService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). + +%% @doc Unary RPC +-spec get_volume(controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Input) -> + get_volume(ctx:new(), Input, #{}). + +-spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume(Ctx, Input, #{}); +get_volume(Input, Options) -> + get_volume(ctx:new(), Input, Options). + +-spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volumes(controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Input) -> + list_volumes(ctx:new(), Input, #{}). + +-spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> + list_volumes(Ctx, Input, #{}); +list_volumes(Input, Options) -> + list_volumes(ctx:new(), Input, Options). + +-spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). + +%% @doc Unary RPC +-spec create_volume(controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Input) -> + create_volume(ctx:new(), Input, #{}). + +-spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input) when ?is_ctx(Ctx) -> + create_volume(Ctx, Input, #{}); +create_volume(Input, Options) -> + create_volume(ctx:new(), Input, Options). + +-spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec update_volume(controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Input) -> + update_volume(ctx:new(), Input, #{}). + +-spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input) when ?is_ctx(Ctx) -> + update_volume(Ctx, Input, #{}); +update_volume(Input, Options) -> + update_volume(ctx:new(), Input, Options). + +-spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec delete_volume(controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Input) -> + delete_volume(ctx:new(), Input, #{}). + +-spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> + delete_volume(Ctx, Input, #{}); +delete_volume(Input, Options) -> + delete_volume(ctx:new(), Input, Options). + +-spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Input) -> + list_volume_attachments(ctx:new(), Input, #{}). + +-spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> + list_volume_attachments(Ctx, Input, #{}); +list_volume_attachments(Input, Options) -> + list_volume_attachments(ctx:new(), Input, Options). + +-spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). + +%% @doc Unary RPC +-spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Input) -> + get_volume_attachment(ctx:new(), Input, #{}). + +-spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume_attachment(Ctx, Input, #{}); +get_volume_attachment(Input, Options) -> + get_volume_attachment(ctx:new(), Input, Options). + +-spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec attach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Input) -> + attach_volume(ctx:new(), Input, #{}). + +-spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + attach_volume(Ctx, Input, #{}); +attach_volume(Input, Options) -> + attach_volume(ctx:new(), Input, Options). + +-spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec detach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Input) -> + detach_volume(ctx:new(), Input, #{}). + +-spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + detach_volume(Ctx, Input, #{}); +detach_volume(Input, Options) -> + detach_volume(ctx:new(), Input, Options). + +-spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_port_forwarding(controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Input) -> + get_port_forwarding(ctx:new(), Input, #{}). + +-spec get_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + get_port_forwarding(Ctx, Input, #{}); +get_port_forwarding(Input, Options) -> + get_port_forwarding(ctx:new(), Input, Options). + +-spec get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_port_forwardings(controller_pb:list_port_forwardings_request()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Input) -> + list_port_forwardings(ctx:new(), Input, #{}). + +-spec list_port_forwardings(ctx:t() | controller_pb:list_port_forwardings_request(), controller_pb:list_port_forwardings_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> + list_port_forwardings(Ctx, Input, #{}); +list_port_forwardings(Input, Options) -> + list_port_forwardings(ctx:new(), Input, Options). + +-spec list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). + +%% @doc Unary RPC +-spec put_port_forwarding(controller_pb:put_port_forwarding_request()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Input) -> + put_port_forwarding(ctx:new(), Input, #{}). + +-spec put_port_forwarding(ctx:t() | controller_pb:put_port_forwarding_request(), controller_pb:put_port_forwarding_request() | grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + put_port_forwarding(Ctx, Input, #{}); +put_port_forwarding(Input, Options) -> + put_port_forwarding(ctx:new(), Input, Options). + +-spec put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request(), grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). + +%% @doc Unary RPC +-spec delete_port_forwarding(controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Input) -> + delete_port_forwarding(ctx:new(), Input, #{}). + +-spec delete_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + delete_port_forwarding(Ctx, Input, #{}); +delete_port_forwarding(Input, Options) -> + delete_port_forwarding(ctx:new(), Input, Options). + +-spec delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_route_table(controller_pb:route_table_identifier()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Input) -> + get_route_table(ctx:new(), Input, #{}). + +-spec get_route_table(ctx:t() | controller_pb:route_table_identifier(), controller_pb:route_table_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + get_route_table(Ctx, Input, #{}); +get_route_table(Input, Options) -> + get_route_table(ctx:new(), Input, Options). + +-spec get_route_table(ctx:t(), controller_pb:route_table_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetRouteTable">>, Input, ?DEF(route_table_identifier, route_table, <<"RouteTableIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_route_tables(controller_pb:list_route_tables_request()) -> + {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Input) -> + list_route_tables(ctx:new(), Input, #{}). + +-spec list_route_tables(ctx:t() | controller_pb:list_route_tables_request(), controller_pb:list_route_tables_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Ctx, Input) when ?is_ctx(Ctx) -> + list_route_tables(Ctx, Input, #{}); +list_route_tables(Input, Options) -> + list_route_tables(ctx:new(), Input, Options). + +-spec list_route_tables(ctx:t(), controller_pb:list_route_tables_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListRouteTables">>, Input, ?DEF(list_route_tables_request, list_route_tables_response, <<"ListRouteTablesRequest">>), Options). + +%% @doc Unary RPC +-spec create_route_table(controller_pb:create_route_table_request()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Input) -> + create_route_table(ctx:new(), Input, #{}). + +-spec create_route_table(ctx:t() | controller_pb:create_route_table_request(), controller_pb:create_route_table_request() | grpcbox_client:options()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + create_route_table(Ctx, Input, #{}); +create_route_table(Input, Options) -> + create_route_table(ctx:new(), Input, Options). + +-spec create_route_table(ctx:t(), controller_pb:create_route_table_request(), grpcbox_client:options()) -> + {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/CreateRouteTable">>, Input, ?DEF(create_route_table_request, route_table, <<"CreateRouteTableRequest">>), Options). + +%% @doc Unary RPC +-spec delete_route_table(controller_pb:route_table_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Input) -> + delete_route_table(ctx:new(), Input, #{}). + +-spec delete_route_table(ctx:t() | controller_pb:route_table_identifier(), controller_pb:route_table_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + delete_route_table(Ctx, Input, #{}); +delete_route_table(Input, Options) -> + delete_route_table(ctx:new(), Input, Options). + +-spec delete_route_table(ctx:t(), controller_pb:route_table_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteRouteTable">>, Input, ?DEF(route_table_identifier, empty, <<"RouteTableIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_route(controller_pb:route_identifier()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Input) -> + get_route(ctx:new(), Input, #{}). + +-spec get_route(ctx:t() | controller_pb:route_identifier(), controller_pb:route_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Ctx, Input) when ?is_ctx(Ctx) -> + get_route(Ctx, Input, #{}); +get_route(Input, Options) -> + get_route(ctx:new(), Input, Options). + +-spec get_route(ctx:t(), controller_pb:route_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/GetRoute">>, Input, ?DEF(route_identifier, route, <<"RouteIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_routes(controller_pb:list_routes_request()) -> + {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Input) -> + list_routes(ctx:new(), Input, #{}). + +-spec list_routes(ctx:t() | controller_pb:list_routes_request(), controller_pb:list_routes_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Ctx, Input) when ?is_ctx(Ctx) -> + list_routes(Ctx, Input, #{}); +list_routes(Input, Options) -> + list_routes(ctx:new(), Input, Options). + +-spec list_routes(ctx:t(), controller_pb:list_routes_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/ListRoutes">>, Input, ?DEF(list_routes_request, list_routes_response, <<"ListRoutesRequest">>), Options). + +%% @doc Unary RPC +-spec put_route(controller_pb:put_route_request()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Input) -> + put_route(ctx:new(), Input, #{}). + +-spec put_route(ctx:t() | controller_pb:put_route_request(), controller_pb:put_route_request() | grpcbox_client:options()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Ctx, Input) when ?is_ctx(Ctx) -> + put_route(Ctx, Input, #{}); +put_route(Input, Options) -> + put_route(ctx:new(), Input, Options). + +-spec put_route(ctx:t(), controller_pb:put_route_request(), grpcbox_client:options()) -> + {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/PutRoute">>, Input, ?DEF(put_route_request, route, <<"PutRouteRequest">>), Options). + +%% @doc Unary RPC +-spec delete_route(controller_pb:route_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Input) -> + delete_route(ctx:new(), Input, #{}). + +-spec delete_route(ctx:t() | controller_pb:route_identifier(), controller_pb:route_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Ctx, Input) when ?is_ctx(Ctx) -> + delete_route(Ctx, Input, #{}); +delete_route(Input, Options) -> + delete_route(ctx:new(), Input, Options). + +-spec delete_route(ctx:t(), controller_pb:route_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteRoute">>, Input, ?DEF(route_identifier, empty, <<"RouteIdentifier">>), Options). + +%% @doc Unary RPC +-spec sync_routes(controller_pb:sync_routes_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Input) -> + sync_routes(ctx:new(), Input, #{}). + +-spec sync_routes(ctx:t() | controller_pb:sync_routes_request(), controller_pb:sync_routes_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Ctx, Input) when ?is_ctx(Ctx) -> + sync_routes(Ctx, Input, #{}); +sync_routes(Input, Options) -> + sync_routes(ctx:new(), Input, Options). + +-spec sync_routes(ctx:t(), controller_pb:sync_routes_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/ControllerService/SyncRoutes">>, Input, ?DEF(sync_routes_request, empty, <<"SyncRoutesRequest">>), Options). + diff --git a/virtuerl/src/pb/daemon_pb.erl b/virtuerl/src/pb/daemon_pb.erl new file mode 100644 index 0000000..47d53fc --- /dev/null +++ b/virtuerl/src/pb/daemon_pb.erl @@ -0,0 +1,5962 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(daemon_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type sync_routes_request() :: + #{ + }. + +-type empty() :: + #{ + }. + +-type start_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata() % = 2, optional + }. + +-type stop_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata(), % = 2, optional + force => boolean() | 0 | 1 % = 3, optional + }. + +-type get_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type domain() :: + #{id => non_neg_integer(), % = 1, optional, 64 bits + uuid => unicode:chardata(), % = 2, optional + name => unicode:chardata(), % = 3, optional + vcpu => non_neg_integer(), % = 4, optional, 32 bits + memory => non_neg_integer(), % = 5, optional, 64 bits + network => unicode:chardata(), % = 6, optional + bridge => unicode:chardata(), % = 7, optional + state => unicode:chardata(), % = 8, optional + private_ip => unicode:chardata(), % = 9, optional + ipv6_address => unicode:chardata(), % = 15, optional + user_data => unicode:chardata(), % = 10, optional + nested_virtualization => boolean() | 0 | 1, % = 11, optional + base_image => unicode:chardata(), % = 12, optional + created_at => timestamp(), % = 13, optional + os_type => unicode:chardata() % = 14, optional + }. + +-type list_domains_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_domains_response() :: + #{domains => [domain()] % = 1, repeated + }. + +-type create_domain_request() :: + #{domain => domain(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type download_image_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type image_chunk() :: + #{bytes => iodata() % = 1, optional + }. + +-type get_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type network() :: + #{uuid => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + cidr => unicode:chardata(), % = 3, optional + cidr6 => unicode:chardata() % = 4, optional + }. + +-type list_networks_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_networks_response() :: + #{networks => [network()] % = 1, repeated + }. + +-type create_network_request() :: + #{network => network(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type get_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume() :: + #{id => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + size => non_neg_integer() % = 3, optional, 64 bits + }. + +-type list_volumes_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_volumes_response() :: + #{volumes => [volume()] % = 1, repeated + }. + +-type create_volume_request() :: + #{volume => volume(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type update_volume_request() :: + #{host => unicode:chardata(), % = 1, optional + volume => volume() % = 2, optional + }. + +-type delete_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume_attachment_identifier() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + host => unicode:chardata() % = 3, optional + }. + +-type volume_attachment() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + disk_address => unicode:chardata() % = 3, optional + }. + +-type list_volume_attachments_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type list_volume_attachments_response() :: + #{attachments => [volume_attachment()] % = 1, repeated + }. + +-type port_forwarding_identifier() :: + #{host => unicode:chardata(), % = 1, optional + protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer() % = 3, optional, 32 bits + }. + +-type port_forwarding() :: + #{protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer(), % = 3, optional, 32 bits + target_ip => unicode:chardata(), % = 4, optional + target_port => non_neg_integer() % = 5, optional, 32 bits + }. + +-type list_port_forwardings_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_port_forwardings_response() :: + #{port_forwardings => [port_forwarding()] % = 1, repeated + }. + +-type put_port_forwarding_request() :: + #{port_forwarding => port_forwarding(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type timestamp() :: + #{seconds => integer(), % = 1, optional, 64 bits + nanos => integer() % = 2, optional, 32 bits + }. + +-export_type(['sync_routes_request'/0, 'empty'/0, 'start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'timestamp'/0]). +-type '$msg_name'() :: sync_routes_request | empty | start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | timestamp. +-type '$msg'() :: sync_routes_request() | empty() | start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | timestamp(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + sync_routes_request -> encode_msg_sync_routes_request(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); + start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); + stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); + get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); + domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); + list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); + list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); + create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); + delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); + download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); + image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); + get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); + network -> encode_msg_network(id(Msg, TrUserData), TrUserData); + list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); + list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); + create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); + delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); + get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); + volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); + list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); + list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); + create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); + update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); + delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); + volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); + volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); + list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); + list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); + port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); + port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); + list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); + list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); + put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); + timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_sync_routes_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{force := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= false -> B2; + true -> e_type_bool(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). + + +encode_msg_domain(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{name := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + B4 = case M of + #{vcpu := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end, + B5 = case M of + #{memory := F5} -> + begin + TrF5 = id(F5, TrUserData), + if TrF5 =:= 0 -> B4; + true -> e_varint(TrF5, <>, TrUserData) + end + end; + _ -> B4 + end, + B6 = case M of + #{network := F6} -> + begin + TrF6 = id(F6, TrUserData), + case is_empty_string(TrF6) of + true -> B5; + false -> e_type_string(TrF6, <>, TrUserData) + end + end; + _ -> B5 + end, + B7 = case M of + #{bridge := F7} -> + begin + TrF7 = id(F7, TrUserData), + case is_empty_string(TrF7) of + true -> B6; + false -> e_type_string(TrF7, <>, TrUserData) + end + end; + _ -> B6 + end, + B8 = case M of + #{state := F8} -> + begin + TrF8 = id(F8, TrUserData), + case is_empty_string(TrF8) of + true -> B7; + false -> e_type_string(TrF8, <>, TrUserData) + end + end; + _ -> B7 + end, + B9 = case M of + #{private_ip := F9} -> + begin + TrF9 = id(F9, TrUserData), + case is_empty_string(TrF9) of + true -> B8; + false -> e_type_string(TrF9, <>, TrUserData) + end + end; + _ -> B8 + end, + B10 = case M of + #{ipv6_address := F10} -> + begin + TrF10 = id(F10, TrUserData), + case is_empty_string(TrF10) of + true -> B9; + false -> e_type_string(TrF10, <>, TrUserData) + end + end; + _ -> B9 + end, + B11 = case M of + #{user_data := F11} -> + begin + TrF11 = id(F11, TrUserData), + case is_empty_string(TrF11) of + true -> B10; + false -> e_type_string(TrF11, <>, TrUserData) + end + end; + _ -> B10 + end, + B12 = case M of + #{nested_virtualization := F12} -> + begin + TrF12 = id(F12, TrUserData), + if TrF12 =:= false -> B11; + true -> e_type_bool(TrF12, <>, TrUserData) + end + end; + _ -> B11 + end, + B13 = case M of + #{base_image := F13} -> + begin + TrF13 = id(F13, TrUserData), + case is_empty_string(TrF13) of + true -> B12; + false -> e_type_string(TrF13, <>, TrUserData) + end + end; + _ -> B12 + end, + B14 = case M of + #{created_at := F14} -> + begin + TrF14 = id(F14, TrUserData), + if TrF14 =:= undefined -> B13; + true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) + end + end; + _ -> B13 + end, + case M of + #{os_type := F15} -> + begin + TrF15 = id(F15, TrUserData), + case is_empty_string(TrF15) of + true -> B14; + false -> e_type_string(TrF15, <>, TrUserData) + end + end; + _ -> B14 + end. + +encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> + case M of + #{domains := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). + + +encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). + + +encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> + case M of + #{bytes := F1} -> + begin + TrF1 = id(F1, TrUserData), + case iolist_size(TrF1) of + 0 -> Bin; + _ -> e_type_bytes(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). + + +encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). + + +encode_msg_network(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{cidr := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{cidr6 := F4} -> + begin + TrF4 = id(F4, TrUserData), + case is_empty_string(TrF4) of + true -> B3; + false -> e_type_string(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> + case M of + #{networks := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). + + +encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{network := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). + + +encode_msg_volume(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{size := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> + case M of + #{volumes := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{volume := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{volume := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= undefined -> B1; + true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{host := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{disk_address := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> + case M of + #{attachments := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{protocol := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{source_port := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{protocol := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{source_port := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_varint(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{target_ip := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{target_port := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> + case M of + #{port_forwardings := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). + + +encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{port_forwarding := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). + + +encode_msg_timestamp(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{seconds := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_type_int64(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{nanos := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_type_int32(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +e_mfield_domain_created_at(Msg, Bin, TrUserData) -> + SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_domains_response_domains(Rest, Bin3, TrUserData); +e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. + +e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_networks_response_networks(Rest, Bin3, TrUserData); +e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. + +e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); +e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. + +e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); +e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. + +e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); +e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. + +e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(sync_routes_request, Bin, TrUserData) -> id(decode_msg_sync_routes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); +decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). + + + +decode_msg_sync_routes_request(Bin, TrUserData) -> dfp_read_field_def_sync_routes_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_sync_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_routes_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_sync_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_sync_routes_request(Rest2, 0, 0, F, TrUserData). + +skip_group_sync_routes_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_sync_routes_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_sync_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_sync_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; +dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. + +d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). + +dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; +dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. + +d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_domain(Bin, TrUserData) -> + dfp_read_field_def_domain(Bin, + 0, + 0, + 0, + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(0, TrUserData), + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(false, TrUserData), + id(<<>>, TrUserData), + id('$undef', TrUserData), + id(<<>>, TrUserData), + TrUserData). + +dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end; +dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> + dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) + end + end; +dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end. + +d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). + +d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, + 0, + 0, + F, + F@_1, + F@_2, + F@_3, + F@_4, + F@_5, + F@_6, + F@_7, + F@_8, + F@_9, + F@_10, + F@_11, + F@_12, + F@_13, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) + end, + F@_15, + TrUserData). + +d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). + +skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end. + +d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end; +dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end. + +d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_domain(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; +dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. + +d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; +dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. + +d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end. + +d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end; +dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end. + +d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_network(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; +dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. + +d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end; +dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end. + +d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end; +dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end. + +d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, + 0, + 0, + F, + F@_1, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; +dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. + +d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; +dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. + +d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; +dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. + +d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; +dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. + +d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end. + +d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end; +dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end. + +d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; +dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. + +d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + sync_routes_request -> merge_msg_sync_routes_request(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData); + start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); + stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); + get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); + domain -> merge_msg_domain(Prev, New, TrUserData); + list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); + list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); + create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); + delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); + download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); + image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); + get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); + network -> merge_msg_network(Prev, New, TrUserData); + list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); + list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); + create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); + delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); + get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); + volume -> merge_msg_volume(Prev, New, TrUserData); + list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); + list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); + create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); + update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); + delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); + volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); + volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); + list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); + list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); + port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); + port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); + list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); + list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); + put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); + timestamp -> merge_msg_timestamp(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_sync_routes_request/3}). +merge_msg_sync_routes_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_start_domain_request/3}). +merge_msg_start_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). +merge_msg_stop_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{force := NFforce}} -> S3#{force => NFforce}; + {#{force := PFforce}, _} -> S3#{force => PFforce}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_get_domain_request/3}). +merge_msg_get_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_domain/3}). +merge_msg_domain(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S3#{name => NFname}; + {#{name := PFname}, _} -> S3#{name => PFname}; + _ -> S3 + end, + S5 = case {PMsg, NMsg} of + {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; + {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; + _ -> S4 + end, + S6 = case {PMsg, NMsg} of + {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; + {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; + _ -> S5 + end, + S7 = case {PMsg, NMsg} of + {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; + _ -> S6 + end, + S8 = case {PMsg, NMsg} of + {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; + {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; + _ -> S7 + end, + S9 = case {PMsg, NMsg} of + {_, #{state := NFstate}} -> S8#{state => NFstate}; + {#{state := PFstate}, _} -> S8#{state => PFstate}; + _ -> S8 + end, + S10 = case {PMsg, NMsg} of + {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; + {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; + _ -> S9 + end, + S11 = case {PMsg, NMsg} of + {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; + {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; + _ -> S10 + end, + S12 = case {PMsg, NMsg} of + {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; + {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; + _ -> S11 + end, + S13 = case {PMsg, NMsg} of + {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; + {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; + _ -> S12 + end, + S14 = case {PMsg, NMsg} of + {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; + {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; + _ -> S13 + end, + S15 = case {PMsg, NMsg} of + {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; + {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; + {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; + {_, _} -> S14 + end, + case {PMsg, NMsg} of + {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; + {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; + _ -> S15 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_request/3}). +merge_msg_list_domains_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_response/3}). +merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; + {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; + {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_domain_request/3}). +merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; + {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; + {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). +merge_msg_delete_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_download_image_request/3}). +merge_msg_download_image_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_image_chunk/3}). +merge_msg_image_chunk(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; + {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_get_network_request/3}). +merge_msg_get_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_network/3}). +merge_msg_network(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; + {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; + {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_request/3}). +merge_msg_list_networks_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_response/3}). +merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; + {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; + {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_network_request/3}). +merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; + {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_network_request/3}). +merge_msg_delete_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_get_volume_request/3}). +merge_msg_get_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume/3}). +merge_msg_volume(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{size := NFsize}} -> S3#{size => NFsize}; + {#{size := PFsize}, _} -> S3#{size => PFsize}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). +merge_msg_list_volumes_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). +merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; + {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; + {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_volume_request/3}). +merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_update_volume_request/3}). +merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; + {_, _} -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). +merge_msg_delete_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). +merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S3#{host => NFhost}; + {#{host := PFhost}, _} -> S3#{host => PFhost}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment/3}). +merge_msg_volume_attachment(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; + {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). +merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). +merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; + {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; + {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). +merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding/3}). +merge_msg_port_forwarding(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; + {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; + {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). +merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). +merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; + {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; + {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). +merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; + {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; + {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_timestamp/3}). +merge_msg_timestamp(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; + {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; + {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; + _ -> S2 + end. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + sync_routes_request -> v_msg_sync_routes_request(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); + stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); + get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); + domain -> v_msg_domain(Msg, [MsgName], TrUserData); + list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); + list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); + create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); + delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); + download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); + image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); + get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); + network -> v_msg_network(Msg, [MsgName], TrUserData); + list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); + list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); + create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); + delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); + get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); + volume -> v_msg_volume(Msg, [MsgName], TrUserData); + list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); + list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); + create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); + update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); + delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); + volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); + volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); + list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); + list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); + port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); + port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); + list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); + list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); + put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); + timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_sync_routes_request/3}). +-dialyzer({nowarn_function,v_msg_sync_routes_request/3}). +v_msg_sync_routes_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_sync_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_routes_request}, M, Path); +v_msg_sync_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_routes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_msg_start_domain_request/3}). +-dialyzer({nowarn_function,v_msg_start_domain_request/3}). +v_msg_start_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); +v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_stop_domain_request/3}). +-dialyzer({nowarn_function,v_msg_stop_domain_request/3}). +v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (force) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); +v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_domain_request/3}). +-dialyzer({nowarn_function,v_msg_get_domain_request/3}). +v_msg_get_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); +v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_domain/3}). +-dialyzer({nowarn_function,v_msg_domain/3}). +v_msg_domain(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); + _ -> ok + end, + case M of + #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); + _ -> ok + end, + case M of + #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); + _ -> ok + end, + case M of + #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); + _ -> ok + end, + case M of + #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); + _ -> ok + end, + case M of + #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); + _ -> ok + end, + case M of + #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); + _ -> ok + end, + case M of + #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); + _ -> ok + end, + case M of + #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); + _ -> ok + end, + case M of + #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (uuid) -> ok; + (name) -> ok; + (vcpu) -> ok; + (memory) -> ok; + (network) -> ok; + (bridge) -> ok; + (state) -> ok; + (private_ip) -> ok; + (ipv6_address) -> ok; + (user_data) -> ok; + (nested_virtualization) -> ok; + (base_image) -> ok; + (created_at) -> ok; + (os_type) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); +v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_request/3}). +-dialyzer({nowarn_function,v_msg_list_domains_request/3}). +v_msg_list_domains_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); +v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_response/3}). +-dialyzer({nowarn_function,v_msg_list_domains_response/3}). +v_msg_list_domains_response(#{} = M, Path, TrUserData) -> + case M of + #{domains := F1} -> + if is_list(F1) -> + _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) + end; + _ -> ok + end, + lists:foreach(fun (domains) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); +v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_domain_request/3}). +-dialyzer({nowarn_function,v_msg_create_domain_request/3}). +v_msg_create_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); +v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_domain_request/3}). +-dialyzer({nowarn_function,v_msg_delete_domain_request/3}). +v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); +v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_download_image_request/3}). +-dialyzer({nowarn_function,v_msg_download_image_request/3}). +v_msg_download_image_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); +v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_image_chunk/3}). +-dialyzer({nowarn_function,v_msg_image_chunk/3}). +v_msg_image_chunk(#{} = M, Path, TrUserData) -> + case M of + #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (bytes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); +v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_network_request/3}). +-dialyzer({nowarn_function,v_msg_get_network_request/3}). +v_msg_get_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); +v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_network/3}). +-dialyzer({nowarn_function,v_msg_network/3}). +v_msg_network(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (name) -> ok; + (cidr) -> ok; + (cidr6) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); +v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_request/3}). +-dialyzer({nowarn_function,v_msg_list_networks_request/3}). +v_msg_list_networks_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); +v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_response/3}). +-dialyzer({nowarn_function,v_msg_list_networks_response/3}). +v_msg_list_networks_response(#{} = M, Path, TrUserData) -> + case M of + #{networks := F1} -> + if is_list(F1) -> + _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) + end; + _ -> ok + end, + lists:foreach(fun (networks) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); +v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_network_request/3}). +-dialyzer({nowarn_function,v_msg_create_network_request/3}). +v_msg_create_network_request(#{} = M, Path, TrUserData) -> + case M of + #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); +v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_network_request/3}). +-dialyzer({nowarn_function,v_msg_delete_network_request/3}). +v_msg_delete_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); +v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_volume_request/3}). +-dialyzer({nowarn_function,v_msg_get_volume_request/3}). +v_msg_get_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); +v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume/3}). +-dialyzer({nowarn_function,v_msg_volume/3}). +v_msg_volume(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (name) -> ok; + (size) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); +v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_request/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_request/3}). +v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); +v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_response/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_response/3}). +v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> + case M of + #{volumes := F1} -> + if is_list(F1) -> + _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) + end; + _ -> ok + end, + lists:foreach(fun (volumes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); +v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_volume_request/3}). +-dialyzer({nowarn_function,v_msg_create_volume_request/3}). +v_msg_create_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (volume) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); +v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_update_volume_request/3}). +-dialyzer({nowarn_function,v_msg_update_volume_request/3}). +v_msg_update_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (volume) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); +v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_volume_request/3}). +-dialyzer({nowarn_function,v_msg_delete_volume_request/3}). +v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); +v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). +v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); +v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment/3}). +v_msg_volume_attachment(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (disk_address) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); +v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). +v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); +v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). +v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> + case M of + #{attachments := F1} -> + if is_list(F1) -> + _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) + end; + _ -> ok + end, + lists:foreach(fun (attachments) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); +v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). +v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (protocol) -> ok; + (source_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); +v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_port_forwarding/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding/3}). +v_msg_port_forwarding(#{} = M, Path, TrUserData) -> + case M of + #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); + _ -> ok + end, + case M of + #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (protocol) -> ok; + (source_port) -> ok; + (target_ip) -> ok; + (target_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); +v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). +v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); +v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). +v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> + case M of + #{port_forwardings := F1} -> + if is_list(F1) -> + _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) + end; + _ -> ok + end, + lists:foreach(fun (port_forwardings) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); +v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). +-dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). +v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> + case M of + #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (port_forwarding) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); +v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_timestamp/3}). +-dialyzer({nowarn_function,v_msg_timestamp/3}). +v_msg_timestamp(#{} = M, Path, TrUserData) -> + case M of + #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); + _ -> ok + end, + case M of + #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (seconds) -> ok; + (nanos) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); +v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). + +-compile({nowarn_unused_function,v_type_int32/3}). +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); +v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_int64/3}). +-dialyzer({nowarn_function,v_type_int64/3}). +v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); +v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_uint32/3}). +-dialyzer({nowarn_function,v_type_uint32/3}). +v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; +v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); +v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_uint64/3}). +-dialyzer({nowarn_function,v_type_uint64/3}). +v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; +v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); +v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_bool/3}). +-dialyzer({nowarn_function,v_type_bool/3}). +v_type_bool(false, _Path, _TrUserData) -> ok; +v_type_bool(true, _Path, _TrUserData) -> ok; +v_type_bool(0, _Path, _TrUserData) -> ok; +v_type_bool(1, _Path, _TrUserData) -> ok; +v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,v_type_bytes/3}). +-dialyzer({nowarn_function,v_type_bytes/3}). +v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; +v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, sync_routes_request}, []}, + {{msg, empty}, []}, + {{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, stop_domain_request}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, + {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, domain}, + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, + {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, + {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, network}, + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, + {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume}, + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, + {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, + {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, + {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment_identifier}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, + {{msg, port_forwarding_identifier}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, + {{msg, port_forwarding}, + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, + {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. + + +get_msg_names() -> + [sync_routes_request, + empty, + start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + port_forwarding_identifier, + port_forwarding, + list_port_forwardings_request, + list_port_forwardings_response, + put_port_forwarding_request, + timestamp]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> + [sync_routes_request, + empty, + start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + port_forwarding_identifier, + port_forwarding, + list_port_forwardings_request, + list_port_forwardings_response, + put_port_forwarding_request, + timestamp]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(sync_routes_request) -> []; +find_msg_def(empty) -> []; +find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(stop_domain_request) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; +find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(domain) -> + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; +find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; +find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(network) -> + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; +find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume) -> + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; +find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; +find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment_identifier) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; +find_msg_def(port_forwarding_identifier) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(port_forwarding) -> + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; +find_msg_def(put_port_forwarding_request) -> + [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['DaemonService', 'DomainService', 'VolumeService', 'PortForwardingService']. + + +get_service_def('DaemonService') -> + {{service, 'DaemonService'}, + [#{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('DomainService') -> + {{service, 'DomainService'}, + [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('VolumeService') -> + {{service, 'VolumeService'}, + [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def('PortForwardingService') -> + {{service, 'PortForwardingService'}, + [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('DaemonService') -> + ['GetNetwork', + 'ListNetworks', + 'CreateNetwork', + 'DeleteNetwork', + 'StartDomain', + 'StopDomain', + 'GetDomain', + 'ListDomains', + 'CreateDomain', + 'DeleteDomain', + 'DownloadImage', + 'GetVolume', + 'ListVolumes', + 'CreateVolume', + 'UpdateVolume', + 'DeleteVolume', + 'ListVolumeAttachments', + 'GetVolumeAttachment', + 'AttachVolume', + 'DetachVolume', + 'GetPortForwarding', + 'ListPortForwardings', + 'PutPortForwarding', + 'DeletePortForwarding', + 'SyncRoutes']; +get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; +get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; +get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; +get_rpc_names(_) -> error. + + +find_rpc_def('DaemonService', RpcName) -> find_rpc_def_DaemonService(RpcName); +find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); +find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); +find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_DaemonService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_DaemonService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DaemonService(_) -> error. + +find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService(_) -> error. + +find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService(_) -> error. + +find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"DaemonService">>) -> 'DaemonService'; +fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; +fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; +fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('DaemonService') -> <<"DaemonService">>; +service_name_to_fqbin('DomainService') -> <<"DomainService">>; +service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; +service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetNetwork">>) -> {'DaemonService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListNetworks">>) -> {'DaemonService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateNetwork">>) -> {'DaemonService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteNetwork">>) -> {'DaemonService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StartDomain">>) -> {'DaemonService', 'StartDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StopDomain">>) -> {'DaemonService', 'StopDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetDomain">>) -> {'DaemonService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListDomains">>) -> {'DaemonService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateDomain">>) -> {'DaemonService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteDomain">>) -> {'DaemonService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DownloadImage">>) -> {'DaemonService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolume">>) -> {'DaemonService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumes">>) -> {'DaemonService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateVolume">>) -> {'DaemonService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"UpdateVolume">>) -> {'DaemonService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteVolume">>) -> {'DaemonService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumeAttachments">>) -> {'DaemonService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolumeAttachment">>) -> {'DaemonService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"AttachVolume">>) -> {'DaemonService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DetachVolume">>) -> {'DaemonService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetPortForwarding">>) -> {'DaemonService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListPortForwardings">>) -> {'DaemonService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"PutPortForwarding">>) -> {'DaemonService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeletePortForwarding">>) -> {'DaemonService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"SyncRoutes">>) -> {'DaemonService', 'SyncRoutes'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('DaemonService', 'GetNetwork') -> {<<"DaemonService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListNetworks') -> {<<"DaemonService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateNetwork') -> {<<"DaemonService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteNetwork') -> {<<"DaemonService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'StartDomain') -> {<<"DaemonService">>, <<"StartDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'StopDomain') -> {<<"DaemonService">>, <<"StopDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetDomain') -> {<<"DaemonService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListDomains') -> {<<"DaemonService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateDomain') -> {<<"DaemonService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteDomain') -> {<<"DaemonService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DownloadImage') -> {<<"DaemonService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetVolume') -> {<<"DaemonService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumes') -> {<<"DaemonService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'CreateVolume') -> {<<"DaemonService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'UpdateVolume') -> {<<"DaemonService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeleteVolume') -> {<<"DaemonService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumeAttachments') -> {<<"DaemonService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetVolumeAttachment') -> {<<"DaemonService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'AttachVolume') -> {<<"DaemonService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DetachVolume') -> {<<"DaemonService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'GetPortForwarding') -> {<<"DaemonService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'ListPortForwardings') -> {<<"DaemonService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'PutPortForwarding') -> {<<"DaemonService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'DeletePortForwarding') -> {<<"DaemonService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins('DaemonService', 'SyncRoutes') -> {<<"DaemonService">>, <<"SyncRoutes">>}; +service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"SyncRoutesRequest">>) -> sync_routes_request; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; +fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; +fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; +fqbin_to_msg_name(<<"Domain">>) -> domain; +fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; +fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; +fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; +fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; +fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; +fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; +fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; +fqbin_to_msg_name(<<"Network">>) -> network; +fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; +fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; +fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; +fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; +fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; +fqbin_to_msg_name(<<"Volume">>) -> volume; +fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; +fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; +fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; +fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; +fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; +fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; +fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; +fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; +fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; +fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; +fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; +fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; +fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; +fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; +fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(sync_routes_request) -> <<"SyncRoutesRequest">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; +msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; +msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; +msg_name_to_fqbin(domain) -> <<"Domain">>; +msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; +msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; +msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; +msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; +msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; +msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; +msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; +msg_name_to_fqbin(network) -> <<"Network">>; +msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; +msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; +msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; +msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; +msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; +msg_name_to_fqbin(volume) -> <<"Volume">>; +msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; +msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; +msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; +msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; +msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; +msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; +msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; +msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; +msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; +msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; +msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; +msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; +msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; +msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; +msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "daemon.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["daemon.proto", "empty.proto", "domain.proto", "volume.proto", "port_forwarding.proto", "timestamp.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["daemon", "empty", "domain", "volume", "port_forwarding", "timestamp"]. + + +get_msg_containment("daemon") -> [sync_routes_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment("domain") -> + [create_domain_request, + create_network_request, + delete_domain_request, + delete_network_request, + domain, + download_image_request, + get_domain_request, + get_network_request, + image_chunk, + list_domains_request, + list_domains_response, + list_networks_request, + list_networks_response, + network, + start_domain_request, + stop_domain_request]; +get_msg_containment("volume") -> + [create_volume_request, + delete_volume_request, + get_volume_request, + list_volume_attachments_request, + list_volume_attachments_response, + list_volumes_request, + list_volumes_response, + update_volume_request, + volume, + volume_attachment, + volume_attachment_identifier]; +get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; +get_msg_containment("timestamp") -> [timestamp]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("daemon") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment("domain") -> undefined; +get_pkg_containment("volume") -> undefined; +get_pkg_containment("port_forwarding") -> undefined; +get_pkg_containment("timestamp") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("daemon") -> ['DaemonService']; +get_service_containment("empty") -> []; +get_service_containment("domain") -> ['DomainService']; +get_service_containment("volume") -> ['VolumeService']; +get_service_containment("port_forwarding") -> ['PortForwardingService']; +get_service_containment("timestamp") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("daemon") -> + [{'DaemonService', 'GetNetwork'}, + {'DaemonService', 'ListNetworks'}, + {'DaemonService', 'CreateNetwork'}, + {'DaemonService', 'DeleteNetwork'}, + {'DaemonService', 'StartDomain'}, + {'DaemonService', 'StopDomain'}, + {'DaemonService', 'GetDomain'}, + {'DaemonService', 'ListDomains'}, + {'DaemonService', 'CreateDomain'}, + {'DaemonService', 'DeleteDomain'}, + {'DaemonService', 'DownloadImage'}, + {'DaemonService', 'GetVolume'}, + {'DaemonService', 'ListVolumes'}, + {'DaemonService', 'CreateVolume'}, + {'DaemonService', 'UpdateVolume'}, + {'DaemonService', 'DeleteVolume'}, + {'DaemonService', 'ListVolumeAttachments'}, + {'DaemonService', 'GetVolumeAttachment'}, + {'DaemonService', 'AttachVolume'}, + {'DaemonService', 'DetachVolume'}, + {'DaemonService', 'GetPortForwarding'}, + {'DaemonService', 'ListPortForwardings'}, + {'DaemonService', 'PutPortForwarding'}, + {'DaemonService', 'DeletePortForwarding'}, + {'DaemonService', 'SyncRoutes'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment("domain") -> + [{'DomainService', 'GetDomain'}, + {'DomainService', 'ListDomains'}, + {'DomainService', 'CreateDomain'}, + {'DomainService', 'DeleteDomain'}, + {'DomainService', 'DownloadImage'}, + {'DomainService', 'GetNetwork'}, + {'DomainService', 'ListNetworks'}, + {'DomainService', 'CreateNetwork'}, + {'DomainService', 'DeleteNetwork'}]; +get_rpc_containment("volume") -> + [{'VolumeService', 'GetVolume'}, + {'VolumeService', 'ListVolumes'}, + {'VolumeService', 'CreateVolume'}, + {'VolumeService', 'UpdateVolume'}, + {'VolumeService', 'DeleteVolume'}, + {'VolumeService', 'ListVolumeAttachments'}, + {'VolumeService', 'GetVolumeAttachment'}, + {'VolumeService', 'AttachVolume'}, + {'VolumeService', 'DetachVolume'}]; +get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; +get_rpc_containment("timestamp") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("daemon") -> []; +get_enum_containment("empty") -> []; +get_enum_containment("domain") -> []; +get_enum_containment("volume") -> []; +get_enum_containment("port_forwarding") -> []; +get_enum_containment("timestamp") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; +get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"SyncRoutesRequest">>) -> "daemon"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; +get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; +get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; +get_proto_by_service_name_as_fqbin(<<"DaemonService">>) -> "daemon"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/daemon_service_bhvr.erl b/virtuerl/src/pb/daemon_service_bhvr.erl new file mode 100644 index 0000000..a722be8 --- /dev/null +++ b/virtuerl/src/pb/daemon_service_bhvr.erl @@ -0,0 +1,109 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service DaemonService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(daemon_service_bhvr). + +%% Unary RPC +-callback get_network(ctx:t(), controller_pb:get_network_request()) -> + {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_networks(ctx:t(), controller_pb:list_networks_request()) -> + {ok, controller_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_network(ctx:t(), controller_pb:create_network_request()) -> + {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_network(ctx:t(), controller_pb:delete_network_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback start_domain(ctx:t(), controller_pb:start_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback stop_domain(ctx:t(), controller_pb:stop_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_domain(ctx:t(), controller_pb:get_domain_request()) -> + {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_domains(ctx:t(), controller_pb:list_domains_request()) -> + {ok, controller_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_domain(ctx:t(), controller_pb:create_domain_request()) -> + {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_domain(ctx:t(), controller_pb:delete_domain_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% +-callback download_image(controller_pb:download_image_request(), grpcbox_stream:t()) -> + ok | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request()) -> + {ok, controller_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request()) -> + {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback sync_routes(ctx:t(), controller_pb:sync_routes_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/daemon_service_client.erl b/virtuerl/src/pb/daemon_service_client.erl new file mode 100644 index 0000000..d02ee59 --- /dev/null +++ b/virtuerl/src/pb/daemon_service_client.erl @@ -0,0 +1,475 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service DaemonService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(daemon_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'DaemonService'). +-define(PROTO_MODULE, 'controller_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_network(controller_pb:get_network_request()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Input) -> + get_network(ctx:new(), Input, #{}). + +-spec get_network(ctx:t() | controller_pb:get_network_request(), controller_pb:get_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input) when ?is_ctx(Ctx) -> + get_network(Ctx, Input, #{}); +get_network(Input, Options) -> + get_network(ctx:new(), Input, Options). + +-spec get_network(ctx:t(), controller_pb:get_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec list_networks(controller_pb:list_networks_request()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Input) -> + list_networks(ctx:new(), Input, #{}). + +-spec list_networks(ctx:t() | controller_pb:list_networks_request(), controller_pb:list_networks_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input) when ?is_ctx(Ctx) -> + list_networks(Ctx, Input, #{}); +list_networks(Input, Options) -> + list_networks(ctx:new(), Input, Options). + +-spec list_networks(ctx:t(), controller_pb:list_networks_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). + +%% @doc Unary RPC +-spec create_network(controller_pb:create_network_request()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Input) -> + create_network(ctx:new(), Input, #{}). + +-spec create_network(ctx:t() | controller_pb:create_network_request(), controller_pb:create_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input) when ?is_ctx(Ctx) -> + create_network(Ctx, Input, #{}); +create_network(Input, Options) -> + create_network(ctx:new(), Input, Options). + +-spec create_network(ctx:t(), controller_pb:create_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec delete_network(controller_pb:delete_network_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Input) -> + delete_network(ctx:new(), Input, #{}). + +-spec delete_network(ctx:t() | controller_pb:delete_network_request(), controller_pb:delete_network_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input) when ?is_ctx(Ctx) -> + delete_network(Ctx, Input, #{}); +delete_network(Input, Options) -> + delete_network(ctx:new(), Input, Options). + +-spec delete_network(ctx:t(), controller_pb:delete_network_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec start_domain(controller_pb:start_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Input) -> + start_domain(ctx:new(), Input, #{}). + +-spec start_domain(ctx:t() | controller_pb:start_domain_request(), controller_pb:start_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Ctx, Input) when ?is_ctx(Ctx) -> + start_domain(Ctx, Input, #{}); +start_domain(Input, Options) -> + start_domain(ctx:new(), Input, Options). + +-spec start_domain(ctx:t(), controller_pb:start_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +start_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/StartDomain">>, Input, ?DEF(start_domain_request, empty, <<"StartDomainRequest">>), Options). + +%% @doc Unary RPC +-spec stop_domain(controller_pb:stop_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Input) -> + stop_domain(ctx:new(), Input, #{}). + +-spec stop_domain(ctx:t() | controller_pb:stop_domain_request(), controller_pb:stop_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Ctx, Input) when ?is_ctx(Ctx) -> + stop_domain(Ctx, Input, #{}); +stop_domain(Input, Options) -> + stop_domain(ctx:new(), Input, Options). + +-spec stop_domain(ctx:t(), controller_pb:stop_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +stop_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/StopDomain">>, Input, ?DEF(stop_domain_request, empty, <<"StopDomainRequest">>), Options). + +%% @doc Unary RPC +-spec get_domain(controller_pb:get_domain_request()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Input) -> + get_domain(ctx:new(), Input, #{}). + +-spec get_domain(ctx:t() | controller_pb:get_domain_request(), controller_pb:get_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input) when ?is_ctx(Ctx) -> + get_domain(Ctx, Input, #{}); +get_domain(Input, Options) -> + get_domain(ctx:new(), Input, Options). + +-spec get_domain(ctx:t(), controller_pb:get_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). + +%% @doc Unary RPC +-spec list_domains(controller_pb:list_domains_request()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Input) -> + list_domains(ctx:new(), Input, #{}). + +-spec list_domains(ctx:t() | controller_pb:list_domains_request(), controller_pb:list_domains_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input) when ?is_ctx(Ctx) -> + list_domains(Ctx, Input, #{}); +list_domains(Input, Options) -> + list_domains(ctx:new(), Input, Options). + +-spec list_domains(ctx:t(), controller_pb:list_domains_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). + +%% @doc Unary RPC +-spec create_domain(controller_pb:create_domain_request()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Input) -> + create_domain(ctx:new(), Input, #{}). + +-spec create_domain(ctx:t() | controller_pb:create_domain_request(), controller_pb:create_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input) when ?is_ctx(Ctx) -> + create_domain(Ctx, Input, #{}); +create_domain(Input, Options) -> + create_domain(ctx:new(), Input, Options). + +-spec create_domain(ctx:t(), controller_pb:create_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). + +%% @doc Unary RPC +-spec delete_domain(controller_pb:delete_domain_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Input) -> + delete_domain(ctx:new(), Input, #{}). + +-spec delete_domain(ctx:t() | controller_pb:delete_domain_request(), controller_pb:delete_domain_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> + delete_domain(Ctx, Input, #{}); +delete_domain(Input, Options) -> + delete_domain(ctx:new(), Input, Options). + +-spec delete_domain(ctx:t(), controller_pb:delete_domain_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). + +%% @doc +-spec download_image(controller_pb:download_image_request()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Input) -> + download_image(ctx:new(), Input, #{}). + +-spec download_image(ctx:t() | controller_pb:download_image_request(), controller_pb:download_image_request() | grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input) when ?is_ctx(Ctx) -> + download_image(Ctx, Input, #{}); +download_image(Input, Options) -> + download_image(ctx:new(), Input, Options). + +-spec download_image(ctx:t(), controller_pb:download_image_request(), grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input, Options) -> + grpcbox_client:stream(Ctx, <<"/DaemonService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). + +%% @doc Unary RPC +-spec get_volume(controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Input) -> + get_volume(ctx:new(), Input, #{}). + +-spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume(Ctx, Input, #{}); +get_volume(Input, Options) -> + get_volume(ctx:new(), Input, Options). + +-spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volumes(controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Input) -> + list_volumes(ctx:new(), Input, #{}). + +-spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> + list_volumes(Ctx, Input, #{}); +list_volumes(Input, Options) -> + list_volumes(ctx:new(), Input, Options). + +-spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). + +%% @doc Unary RPC +-spec create_volume(controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Input) -> + create_volume(ctx:new(), Input, #{}). + +-spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input) when ?is_ctx(Ctx) -> + create_volume(Ctx, Input, #{}); +create_volume(Input, Options) -> + create_volume(ctx:new(), Input, Options). + +-spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec update_volume(controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Input) -> + update_volume(ctx:new(), Input, #{}). + +-spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input) when ?is_ctx(Ctx) -> + update_volume(Ctx, Input, #{}); +update_volume(Input, Options) -> + update_volume(ctx:new(), Input, Options). + +-spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec delete_volume(controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Input) -> + delete_volume(ctx:new(), Input, #{}). + +-spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> + delete_volume(Ctx, Input, #{}); +delete_volume(Input, Options) -> + delete_volume(ctx:new(), Input, Options). + +-spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Input) -> + list_volume_attachments(ctx:new(), Input, #{}). + +-spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> + list_volume_attachments(Ctx, Input, #{}); +list_volume_attachments(Input, Options) -> + list_volume_attachments(ctx:new(), Input, Options). + +-spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). + +%% @doc Unary RPC +-spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Input) -> + get_volume_attachment(ctx:new(), Input, #{}). + +-spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume_attachment(Ctx, Input, #{}); +get_volume_attachment(Input, Options) -> + get_volume_attachment(ctx:new(), Input, Options). + +-spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec attach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Input) -> + attach_volume(ctx:new(), Input, #{}). + +-spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + attach_volume(Ctx, Input, #{}); +attach_volume(Input, Options) -> + attach_volume(ctx:new(), Input, Options). + +-spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec detach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Input) -> + detach_volume(ctx:new(), Input, #{}). + +-spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + detach_volume(Ctx, Input, #{}); +detach_volume(Input, Options) -> + detach_volume(ctx:new(), Input, Options). + +-spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_port_forwarding(controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Input) -> + get_port_forwarding(ctx:new(), Input, #{}). + +-spec get_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + get_port_forwarding(Ctx, Input, #{}); +get_port_forwarding(Input, Options) -> + get_port_forwarding(ctx:new(), Input, Options). + +-spec get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_port_forwardings(controller_pb:list_port_forwardings_request()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Input) -> + list_port_forwardings(ctx:new(), Input, #{}). + +-spec list_port_forwardings(ctx:t() | controller_pb:list_port_forwardings_request(), controller_pb:list_port_forwardings_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> + list_port_forwardings(Ctx, Input, #{}); +list_port_forwardings(Input, Options) -> + list_port_forwardings(ctx:new(), Input, Options). + +-spec list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). + +%% @doc Unary RPC +-spec put_port_forwarding(controller_pb:put_port_forwarding_request()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Input) -> + put_port_forwarding(ctx:new(), Input, #{}). + +-spec put_port_forwarding(ctx:t() | controller_pb:put_port_forwarding_request(), controller_pb:put_port_forwarding_request() | grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + put_port_forwarding(Ctx, Input, #{}); +put_port_forwarding(Input, Options) -> + put_port_forwarding(ctx:new(), Input, Options). + +-spec put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request(), grpcbox_client:options()) -> + {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). + +%% @doc Unary RPC +-spec delete_port_forwarding(controller_pb:port_forwarding_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Input) -> + delete_port_forwarding(ctx:new(), Input, #{}). + +-spec delete_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + delete_port_forwarding(Ctx, Input, #{}); +delete_port_forwarding(Input, Options) -> + delete_port_forwarding(ctx:new(), Input, Options). + +-spec delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). + +%% @doc Unary RPC +-spec sync_routes(controller_pb:sync_routes_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Input) -> + sync_routes(ctx:new(), Input, #{}). + +-spec sync_routes(ctx:t() | controller_pb:sync_routes_request(), controller_pb:sync_routes_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Ctx, Input) when ?is_ctx(Ctx) -> + sync_routes(Ctx, Input, #{}); +sync_routes(Input, Options) -> + sync_routes(ctx:new(), Input, Options). + +-spec sync_routes(ctx:t(), controller_pb:sync_routes_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync_routes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DaemonService/SyncRoutes">>, Input, ?DEF(sync_routes_request, empty, <<"SyncRoutesRequest">>), Options). + diff --git a/virtuerl/src/pb/dns_bhvr.erl b/virtuerl/src/pb/dns_bhvr.erl new file mode 100644 index 0000000..6c26475 --- /dev/null +++ b/virtuerl/src/pb/dns_bhvr.erl @@ -0,0 +1,25 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service DNS. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(dns_bhvr). + +%% Unary RPC +-callback get_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> + {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_dns_records(ctx:t(), controller_pb:list_dns_records_request()) -> + {ok, controller_pb:list_dns_records_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_dns_record(ctx:t(), controller_pb:put_dns_record_request()) -> + {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/dns_client.erl b/virtuerl/src/pb/dns_client.erl new file mode 100644 index 0000000..527d371 --- /dev/null +++ b/virtuerl/src/pb/dns_client.erl @@ -0,0 +1,97 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service DNS. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(dns_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'DNS'). +-define(PROTO_MODULE, 'controller_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_dns_record(controller_pb:dns_record_identifier()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Input) -> + get_dns_record(ctx:new(), Input, #{}). + +-spec get_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + get_dns_record(Ctx, Input, #{}); +get_dns_record(Input, Options) -> + get_dns_record(ctx:new(), Input, Options). + +-spec get_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DNS/GetDNSRecord">>, Input, ?DEF(dns_record_identifier, dns_record, <<"DNSRecordIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_dns_records(controller_pb:list_dns_records_request()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Input) -> + list_dns_records(ctx:new(), Input, #{}). + +-spec list_dns_records(ctx:t() | controller_pb:list_dns_records_request(), controller_pb:list_dns_records_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Ctx, Input) when ?is_ctx(Ctx) -> + list_dns_records(Ctx, Input, #{}); +list_dns_records(Input, Options) -> + list_dns_records(ctx:new(), Input, Options). + +-spec list_dns_records(ctx:t(), controller_pb:list_dns_records_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_dns_records(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DNS/ListDNSRecords">>, Input, ?DEF(list_dns_records_request, list_dns_records_response, <<"ListDNSRecordsRequest">>), Options). + +%% @doc Unary RPC +-spec put_dns_record(controller_pb:put_dns_record_request()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Input) -> + put_dns_record(ctx:new(), Input, #{}). + +-spec put_dns_record(ctx:t() | controller_pb:put_dns_record_request(), controller_pb:put_dns_record_request() | grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + put_dns_record(Ctx, Input, #{}); +put_dns_record(Input, Options) -> + put_dns_record(ctx:new(), Input, Options). + +-spec put_dns_record(ctx:t(), controller_pb:put_dns_record_request(), grpcbox_client:options()) -> + {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DNS/PutDNSRecord">>, Input, ?DEF(put_dns_record_request, dns_record, <<"PutDNSRecordRequest">>), Options). + +%% @doc Unary RPC +-spec delete_dns_record(controller_pb:dns_record_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Input) -> + delete_dns_record(ctx:new(), Input, #{}). + +-spec delete_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> + delete_dns_record(Ctx, Input, #{}); +delete_dns_record(Input, Options) -> + delete_dns_record(ctx:new(), Input, Options). + +-spec delete_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_dns_record(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DNS/DeleteDNSRecord">>, Input, ?DEF(dns_record_identifier, empty, <<"DNSRecordIdentifier">>), Options). + diff --git a/virtuerl/src/pb/dns_pb.erl b/virtuerl/src/pb/dns_pb.erl new file mode 100644 index 0000000..3f91d8a --- /dev/null +++ b/virtuerl/src/pb/dns_pb.erl @@ -0,0 +1,1228 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(dns_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type dns_record_identifier() :: + #{name => unicode:chardata(), % = 1, optional + type => unicode:chardata() % = 2, optional + }. + +-type dns_record() :: + #{name => unicode:chardata(), % = 1, optional + type => unicode:chardata(), % = 2, optional + ttl => non_neg_integer(), % = 3, optional, 64 bits + records => [unicode:chardata()] % = 4, repeated + }. + +-type list_dns_records_request() :: + #{ + }. + +-type list_dns_records_response() :: + #{dns_records => [dns_record()] % = 1, repeated + }. + +-type put_dns_record_request() :: + #{dns_record => dns_record() % = 1, optional + }. + +-type empty() :: + #{ + }. + +-export_type(['dns_record_identifier'/0, 'dns_record'/0, 'list_dns_records_request'/0, 'list_dns_records_response'/0, 'put_dns_record_request'/0, 'empty'/0]). +-type '$msg_name'() :: dns_record_identifier | dns_record | list_dns_records_request | list_dns_records_response | put_dns_record_request | empty. +-type '$msg'() :: dns_record_identifier() | dns_record() | list_dns_records_request() | list_dns_records_response() | put_dns_record_request() | empty(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + dns_record_identifier -> encode_msg_dns_record_identifier(id(Msg, TrUserData), TrUserData); + dns_record -> encode_msg_dns_record(id(Msg, TrUserData), TrUserData); + list_dns_records_request -> encode_msg_list_dns_records_request(id(Msg, TrUserData), TrUserData); + list_dns_records_response -> encode_msg_list_dns_records_response(id(Msg, TrUserData), TrUserData); + put_dns_record_request -> encode_msg_put_dns_record_request(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_dns_record_identifier(Msg, TrUserData) -> encode_msg_dns_record_identifier(Msg, <<>>, TrUserData). + + +encode_msg_dns_record_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{type := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_dns_record(Msg, TrUserData) -> encode_msg_dns_record(Msg, <<>>, TrUserData). + + +encode_msg_dns_record(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{type := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{ttl := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{records := F4} -> + TrF4 = id(F4, TrUserData), + if TrF4 == [] -> B3; + true -> e_field_dns_record_records(TrF4, B3, TrUserData) + end; + _ -> B3 + end. + +encode_msg_list_dns_records_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_list_dns_records_response(Msg, TrUserData) -> encode_msg_list_dns_records_response(Msg, <<>>, TrUserData). + + +encode_msg_list_dns_records_response(#{} = M, Bin, TrUserData) -> + case M of + #{dns_records := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_dns_records_response_dns_records(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_dns_record_request(Msg, TrUserData) -> encode_msg_put_dns_record_request(Msg, <<>>, TrUserData). + + +encode_msg_put_dns_record_request(#{} = M, Bin, TrUserData) -> + case M of + #{dns_record := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_dns_record_request_dns_record(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +e_field_dns_record_records([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), + e_field_dns_record_records(Rest, Bin3, TrUserData); +e_field_dns_record_records([], Bin, _TrUserData) -> Bin. + +e_mfield_list_dns_records_response_dns_records(Msg, Bin, TrUserData) -> + SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_dns_records_response_dns_records([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_dns_records_response_dns_records(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_dns_records_response_dns_records(Rest, Bin3, TrUserData); +e_field_list_dns_records_response_dns_records([], Bin, _TrUserData) -> Bin. + +e_mfield_put_dns_record_request_dns_record(Msg, Bin, TrUserData) -> + SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(dns_record_identifier, Bin, TrUserData) -> id(decode_msg_dns_record_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(dns_record, Bin, TrUserData) -> id(decode_msg_dns_record(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_dns_records_request, Bin, TrUserData) -> id(decode_msg_list_dns_records_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_dns_records_response, Bin, TrUserData) -> id(decode_msg_list_dns_records_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_dns_record_request, Bin, TrUserData) -> id(decode_msg_put_dns_record_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). + + + +decode_msg_dns_record_identifier(Bin, TrUserData) -> dfp_read_field_def_dns_record_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_dns_record_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_dns_record_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_type(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}; +dfp_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_dns_record_identifier_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_dns_record_identifier_type(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}. + +d_field_dns_record_identifier_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_dns_record_identifier_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_dns_record_identifier_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_dns_record_identifier_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_dns_record_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_dns_record_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_dns_record_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_dns_record_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_dns_record_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_dns_record_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_dns_record_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_dns_record(Bin, TrUserData) -> dfp_read_field_def_dns_record(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id([], TrUserData), TrUserData). + +dfp_read_field_def_dns_record(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_ttl(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_records(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}; +dfp_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_dns_record_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 18 -> d_field_dns_record_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 24 -> d_field_dns_record_ttl(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_dns_record_records(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}. + +d_field_dns_record_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_dns_record_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_dns_record_ttl(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_ttl(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_ttl(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_dns_record_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_records(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_dns_record_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, F@_3, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_dns_record(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_dns_record(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_dns_record(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_dns_record(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_dns_record(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_dns_record(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_dns_record(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_dns_records_request(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_list_dns_records_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_dns_records_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_list_dns_records_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_dns_records_request(Rest2, 0, 0, F, TrUserData). + +skip_group_list_dns_records_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_dns_records_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_list_dns_records_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_list_dns_records_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_list_dns_records_response(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_dns_records_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_dns_records_response_dns_records(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{dns_records => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_dns_records_response_dns_records(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{dns_records => lists_reverse(R1, TrUserData)} + end. + +d_field_list_dns_records_response_dns_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_dns_records_response_dns_records(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_dns_records_response_dns_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_dns_records_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_dns_records_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_dns_records_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_dns_records_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_dns_records_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_dns_records_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_dns_records_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_dns_records_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_dns_record_request(Bin, TrUserData) -> dfp_read_field_def_put_dns_record_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_put_dns_record_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_dns_record_request_dns_record(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{dns_record => F@_1} + end; +dfp_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_dns_record_request_dns_record(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{dns_record => F@_1} + end. + +d_field_put_dns_record_request_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_dns_record_request_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_put_dns_record_request_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_dns_record_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_dns_record(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_put_dns_record_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_put_dns_record_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_dns_record_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_put_dns_record_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_dns_record_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_put_dns_record_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_put_dns_record_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + dns_record_identifier -> merge_msg_dns_record_identifier(Prev, New, TrUserData); + dns_record -> merge_msg_dns_record(Prev, New, TrUserData); + list_dns_records_request -> merge_msg_list_dns_records_request(Prev, New, TrUserData); + list_dns_records_response -> merge_msg_list_dns_records_response(Prev, New, TrUserData); + put_dns_record_request -> merge_msg_put_dns_record_request(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_dns_record_identifier/3}). +merge_msg_dns_record_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S1#{name => NFname}; + {#{name := PFname}, _} -> S1#{name => PFname}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{type := NFtype}} -> S2#{type => NFtype}; + {#{type := PFtype}, _} -> S2#{type => PFtype}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_dns_record/3}). +merge_msg_dns_record(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S1#{name => NFname}; + {#{name := PFname}, _} -> S1#{name => PFname}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{type := NFtype}} -> S2#{type => NFtype}; + {#{type := PFtype}, _} -> S2#{type => PFtype}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{ttl := NFttl}} -> S3#{ttl => NFttl}; + {#{ttl := PFttl}, _} -> S3#{ttl => PFttl}; + _ -> S3 + end, + case {PMsg, NMsg} of + {#{records := PFrecords}, #{records := NFrecords}} -> S4#{records => 'erlang_++'(PFrecords, NFrecords, TrUserData)}; + {_, #{records := NFrecords}} -> S4#{records => NFrecords}; + {#{records := PFrecords}, _} -> S4#{records => PFrecords}; + {_, _} -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_dns_records_request/3}). +merge_msg_list_dns_records_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_list_dns_records_response/3}). +merge_msg_list_dns_records_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{dns_records := PFdns_records}, #{dns_records := NFdns_records}} -> S1#{dns_records => 'erlang_++'(PFdns_records, NFdns_records, TrUserData)}; + {_, #{dns_records := NFdns_records}} -> S1#{dns_records => NFdns_records}; + {#{dns_records := PFdns_records}, _} -> S1#{dns_records => PFdns_records}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_dns_record_request/3}). +merge_msg_put_dns_record_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{dns_record := PFdns_record}, #{dns_record := NFdns_record}} -> S1#{dns_record => merge_msg_dns_record(PFdns_record, NFdns_record, TrUserData)}; + {_, #{dns_record := NFdns_record}} -> S1#{dns_record => NFdns_record}; + {#{dns_record := PFdns_record}, _} -> S1#{dns_record => PFdns_record}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + dns_record_identifier -> v_msg_dns_record_identifier(Msg, [MsgName], TrUserData); + dns_record -> v_msg_dns_record(Msg, [MsgName], TrUserData); + list_dns_records_request -> v_msg_list_dns_records_request(Msg, [MsgName], TrUserData); + list_dns_records_response -> v_msg_list_dns_records_response(Msg, [MsgName], TrUserData); + put_dns_record_request -> v_msg_put_dns_record_request(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_dns_record_identifier/3}). +-dialyzer({nowarn_function,v_msg_dns_record_identifier/3}). +v_msg_dns_record_identifier(#{} = M, Path, TrUserData) -> + case M of + #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (name) -> ok; + (type) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_dns_record_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record_identifier}, M, Path); +v_msg_dns_record_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_dns_record/3}). +-dialyzer({nowarn_function,v_msg_dns_record/3}). +v_msg_dns_record(#{} = M, Path, TrUserData) -> + case M of + #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); + _ -> ok + end, + case M of + #{ttl := F3} -> v_type_uint64(F3, [ttl | Path], TrUserData); + _ -> ok + end, + case M of + #{records := F4} -> + if is_list(F4) -> + _ = [v_type_string(Elem, [records | Path], TrUserData) || Elem <- F4], + ok; + true -> mk_type_error({invalid_list_of, string}, F4, [records | Path]) + end; + _ -> ok + end, + lists:foreach(fun (name) -> ok; + (type) -> ok; + (ttl) -> ok; + (records) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_dns_record(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record}, M, Path); +v_msg_dns_record(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_dns_records_request/3}). +-dialyzer({nowarn_function,v_msg_list_dns_records_request/3}). +v_msg_list_dns_records_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_list_dns_records_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_request}, M, Path); +v_msg_list_dns_records_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_dns_records_response/3}). +-dialyzer({nowarn_function,v_msg_list_dns_records_response/3}). +v_msg_list_dns_records_response(#{} = M, Path, TrUserData) -> + case M of + #{dns_records := F1} -> + if is_list(F1) -> + _ = [v_msg_dns_record(Elem, [dns_records | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, dns_record}}, F1, [dns_records | Path]) + end; + _ -> ok + end, + lists:foreach(fun (dns_records) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_dns_records_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_response}, M, Path); +v_msg_list_dns_records_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_dns_record_request/3}). +-dialyzer({nowarn_function,v_msg_put_dns_record_request/3}). +v_msg_put_dns_record_request(#{} = M, Path, TrUserData) -> + case M of + #{dns_record := F1} -> v_msg_dns_record(F1, [dns_record | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (dns_record) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_dns_record_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_dns_record_request}, M, Path); +v_msg_put_dns_record_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_dns_record_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_type_uint64/3}). +-dialyzer({nowarn_function,v_type_uint64/3}). +v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; +v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); +v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, dns_record_identifier}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, dns_record}, + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, + #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]}, + {{msg, list_dns_records_request}, []}, + {{msg, list_dns_records_response}, [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]}, + {{msg, put_dns_record_request}, [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]}, + {{msg, empty}, []}]. + + +get_msg_names() -> [dns_record_identifier, dns_record, list_dns_records_request, list_dns_records_response, put_dns_record_request, empty]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> [dns_record_identifier, dns_record, list_dns_records_request, list_dns_records_response, put_dns_record_request, empty]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(dns_record_identifier) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(dns_record) -> + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, + #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]; +find_msg_def(list_dns_records_request) -> []; +find_msg_def(list_dns_records_response) -> [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]; +find_msg_def(put_dns_record_request) -> [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]; +find_msg_def(empty) -> []; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['DNS']. + + +get_service_def('DNS') -> + {{service, 'DNS'}, + [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('DNS') -> ['GetDNSRecord', 'ListDNSRecords', 'PutDNSRecord', 'DeleteDNSRecord']; +get_rpc_names(_) -> error. + + +find_rpc_def('DNS', RpcName) -> find_rpc_def_DNS(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_DNS('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DNS(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"DNS">>) -> 'DNS'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('DNS') -> <<"DNS">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"GetDNSRecord">>) -> {'DNS', 'GetDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"ListDNSRecords">>) -> {'DNS', 'ListDNSRecords'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"PutDNSRecord">>) -> {'DNS', 'PutDNSRecord'}; +fqbins_to_service_and_rpc_name(<<"DNS">>, <<"DeleteDNSRecord">>) -> {'DNS', 'DeleteDNSRecord'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('DNS', 'GetDNSRecord') -> {<<"DNS">>, <<"GetDNSRecord">>}; +service_and_rpc_name_to_fqbins('DNS', 'ListDNSRecords') -> {<<"DNS">>, <<"ListDNSRecords">>}; +service_and_rpc_name_to_fqbins('DNS', 'PutDNSRecord') -> {<<"DNS">>, <<"PutDNSRecord">>}; +service_and_rpc_name_to_fqbins('DNS', 'DeleteDNSRecord') -> {<<"DNS">>, <<"DeleteDNSRecord">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"DNSRecordIdentifier">>) -> dns_record_identifier; +fqbin_to_msg_name(<<"DNSRecord">>) -> dns_record; +fqbin_to_msg_name(<<"ListDNSRecordsRequest">>) -> list_dns_records_request; +fqbin_to_msg_name(<<"ListDNSRecordsResponse">>) -> list_dns_records_response; +fqbin_to_msg_name(<<"PutDNSRecordRequest">>) -> put_dns_record_request; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(dns_record_identifier) -> <<"DNSRecordIdentifier">>; +msg_name_to_fqbin(dns_record) -> <<"DNSRecord">>; +msg_name_to_fqbin(list_dns_records_request) -> <<"ListDNSRecordsRequest">>; +msg_name_to_fqbin(list_dns_records_response) -> <<"ListDNSRecordsResponse">>; +msg_name_to_fqbin(put_dns_record_request) -> <<"PutDNSRecordRequest">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "dns.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["dns.proto", "empty.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["dns", "empty"]. + + +get_msg_containment("dns") -> [dns_record, dns_record_identifier, list_dns_records_request, list_dns_records_response, put_dns_record_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("dns") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("dns") -> ['DNS']; +get_service_containment("empty") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("dns") -> [{'DNS', 'GetDNSRecord'}, {'DNS', 'ListDNSRecords'}, {'DNS', 'PutDNSRecord'}, {'DNS', 'DeleteDNSRecord'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("dns") -> []; +get_enum_containment("empty") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"DNSRecordIdentifier">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"PutDNSRecordRequest">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsRequest">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"DNSRecord">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsResponse">>) -> "dns"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"DNS">>) -> "dns"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/domain_pb.erl b/virtuerl/src/pb/domain_pb.erl new file mode 100644 index 0000000..70aab16 --- /dev/null +++ b/virtuerl/src/pb/domain_pb.erl @@ -0,0 +1,3401 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(domain_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type start_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata() % = 2, optional + }. + +-type stop_domain_request() :: + #{host => unicode:chardata(), % = 1, optional + uuid => unicode:chardata(), % = 2, optional + force => boolean() | 0 | 1 % = 3, optional + }. + +-type get_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type domain() :: + #{id => non_neg_integer(), % = 1, optional, 64 bits + uuid => unicode:chardata(), % = 2, optional + name => unicode:chardata(), % = 3, optional + vcpu => non_neg_integer(), % = 4, optional, 32 bits + memory => non_neg_integer(), % = 5, optional, 64 bits + network => unicode:chardata(), % = 6, optional + bridge => unicode:chardata(), % = 7, optional + state => unicode:chardata(), % = 8, optional + private_ip => unicode:chardata(), % = 9, optional + ipv6_address => unicode:chardata(), % = 15, optional + user_data => unicode:chardata(), % = 10, optional + nested_virtualization => boolean() | 0 | 1, % = 11, optional + base_image => unicode:chardata(), % = 12, optional + created_at => timestamp(), % = 13, optional + os_type => unicode:chardata() % = 14, optional + }. + +-type list_domains_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_domains_response() :: + #{domains => [domain()] % = 1, repeated + }. + +-type create_domain_request() :: + #{domain => domain(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_domain_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type download_image_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type image_chunk() :: + #{bytes => iodata() % = 1, optional + }. + +-type get_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type network() :: + #{uuid => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + cidr => unicode:chardata(), % = 3, optional + cidr6 => unicode:chardata() % = 4, optional + }. + +-type list_networks_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_networks_response() :: + #{networks => [network()] % = 1, repeated + }. + +-type create_network_request() :: + #{network => network(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type delete_network_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type empty() :: + #{ + }. + +-type timestamp() :: + #{seconds => integer(), % = 1, optional, 64 bits + nanos => integer() % = 2, optional, 32 bits + }. + +-export_type(['start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'empty'/0, 'timestamp'/0]). +-type '$msg_name'() :: start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | empty | timestamp. +-type '$msg'() :: start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | empty() | timestamp(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); + stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); + get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); + domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); + list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); + list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); + create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); + delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); + download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); + image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); + get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); + network -> encode_msg_network(id(Msg, TrUserData), TrUserData); + list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); + list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); + create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); + delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); + timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{force := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= false -> B2; + true -> e_type_bool(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). + + +encode_msg_domain(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{uuid := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{name := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + B4 = case M of + #{vcpu := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end, + B5 = case M of + #{memory := F5} -> + begin + TrF5 = id(F5, TrUserData), + if TrF5 =:= 0 -> B4; + true -> e_varint(TrF5, <>, TrUserData) + end + end; + _ -> B4 + end, + B6 = case M of + #{network := F6} -> + begin + TrF6 = id(F6, TrUserData), + case is_empty_string(TrF6) of + true -> B5; + false -> e_type_string(TrF6, <>, TrUserData) + end + end; + _ -> B5 + end, + B7 = case M of + #{bridge := F7} -> + begin + TrF7 = id(F7, TrUserData), + case is_empty_string(TrF7) of + true -> B6; + false -> e_type_string(TrF7, <>, TrUserData) + end + end; + _ -> B6 + end, + B8 = case M of + #{state := F8} -> + begin + TrF8 = id(F8, TrUserData), + case is_empty_string(TrF8) of + true -> B7; + false -> e_type_string(TrF8, <>, TrUserData) + end + end; + _ -> B7 + end, + B9 = case M of + #{private_ip := F9} -> + begin + TrF9 = id(F9, TrUserData), + case is_empty_string(TrF9) of + true -> B8; + false -> e_type_string(TrF9, <>, TrUserData) + end + end; + _ -> B8 + end, + B10 = case M of + #{ipv6_address := F10} -> + begin + TrF10 = id(F10, TrUserData), + case is_empty_string(TrF10) of + true -> B9; + false -> e_type_string(TrF10, <>, TrUserData) + end + end; + _ -> B9 + end, + B11 = case M of + #{user_data := F11} -> + begin + TrF11 = id(F11, TrUserData), + case is_empty_string(TrF11) of + true -> B10; + false -> e_type_string(TrF11, <>, TrUserData) + end + end; + _ -> B10 + end, + B12 = case M of + #{nested_virtualization := F12} -> + begin + TrF12 = id(F12, TrUserData), + if TrF12 =:= false -> B11; + true -> e_type_bool(TrF12, <>, TrUserData) + end + end; + _ -> B11 + end, + B13 = case M of + #{base_image := F13} -> + begin + TrF13 = id(F13, TrUserData), + case is_empty_string(TrF13) of + true -> B12; + false -> e_type_string(TrF13, <>, TrUserData) + end + end; + _ -> B12 + end, + B14 = case M of + #{created_at := F14} -> + begin + TrF14 = id(F14, TrUserData), + if TrF14 =:= undefined -> B13; + true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) + end + end; + _ -> B13 + end, + case M of + #{os_type := F15} -> + begin + TrF15 = id(F15, TrUserData), + case is_empty_string(TrF15) of + true -> B14; + false -> e_type_string(TrF15, <>, TrUserData) + end + end; + _ -> B14 + end. + +encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). + + +encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> + case M of + #{domains := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). + + +encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). + + +encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> + case M of + #{bytes := F1} -> + begin + TrF1 = id(F1, TrUserData), + case iolist_size(TrF1) of + 0 -> Bin; + _ -> e_type_bytes(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). + + +encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). + + +encode_msg_network(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{cidr := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{cidr6 := F4} -> + begin + TrF4 = id(F4, TrUserData), + case is_empty_string(TrF4) of + true -> B3; + false -> e_type_string(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). + + +encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> + case M of + #{networks := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). + + +encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{network := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). + + +encode_msg_timestamp(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{seconds := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_type_int64(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{nanos := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_type_int32(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +e_mfield_domain_created_at(Msg, Bin, TrUserData) -> + SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_domains_response_domains(Rest, Bin3, TrUserData); +e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. + +e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> + SubBin = encode_msg_domain(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_networks_response_networks(Rest, Bin3, TrUserData); +e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. + +e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> + SubBin = encode_msg_network(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); +decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); +decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). + + + +decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; +dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. + +d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). + +dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; +dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. + +d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_domain(Bin, TrUserData) -> + dfp_read_field_def_domain(Bin, + 0, + 0, + 0, + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(0, TrUserData), + id(0, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(<<>>, TrUserData), + id(false, TrUserData), + id(<<>>, TrUserData), + id('$undef', TrUserData), + id(<<>>, TrUserData), + TrUserData). + +dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end; +dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> + dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); + 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) + end + end; +dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> + S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, + os_type => F@_15}, + if F@_14 == '$undef' -> S1; + true -> S1#{created_at => F@_14} + end. + +d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). + +d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). + +d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, + 0, + 0, + F, + F@_1, + F@_2, + F@_3, + F@_4, + F@_5, + F@_6, + F@_7, + F@_8, + F@_9, + F@_10, + F@_11, + F@_12, + F@_13, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) + end, + F@_15, + TrUserData). + +d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). + +skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> + skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); +skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> + dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). + +decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{domains => lists_reverse(R1, TrUserData)} + end. + +d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end; +dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{domain => F@_1} + end. + +d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_domain(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; +dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. + +d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; +dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. + +d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{networks => lists_reverse(R1, TrUserData)} + end. + +d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end; +dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{network => F@_1} + end. + +d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_network(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; +dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. + +d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); + stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); + get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); + domain -> merge_msg_domain(Prev, New, TrUserData); + list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); + list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); + create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); + delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); + download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); + image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); + get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); + network -> merge_msg_network(Prev, New, TrUserData); + list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); + list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); + create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); + delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData); + timestamp -> merge_msg_timestamp(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_start_domain_request/3}). +merge_msg_start_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). +merge_msg_stop_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{force := NFforce}} -> S3#{force => NFforce}; + {#{force := PFforce}, _} -> S3#{force => PFforce}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_get_domain_request/3}). +merge_msg_get_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_domain/3}). +merge_msg_domain(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S3#{name => NFname}; + {#{name := PFname}, _} -> S3#{name => PFname}; + _ -> S3 + end, + S5 = case {PMsg, NMsg} of + {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; + {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; + _ -> S4 + end, + S6 = case {PMsg, NMsg} of + {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; + {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; + _ -> S5 + end, + S7 = case {PMsg, NMsg} of + {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; + _ -> S6 + end, + S8 = case {PMsg, NMsg} of + {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; + {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; + _ -> S7 + end, + S9 = case {PMsg, NMsg} of + {_, #{state := NFstate}} -> S8#{state => NFstate}; + {#{state := PFstate}, _} -> S8#{state => PFstate}; + _ -> S8 + end, + S10 = case {PMsg, NMsg} of + {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; + {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; + _ -> S9 + end, + S11 = case {PMsg, NMsg} of + {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; + {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; + _ -> S10 + end, + S12 = case {PMsg, NMsg} of + {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; + {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; + _ -> S11 + end, + S13 = case {PMsg, NMsg} of + {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; + {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; + _ -> S12 + end, + S14 = case {PMsg, NMsg} of + {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; + {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; + _ -> S13 + end, + S15 = case {PMsg, NMsg} of + {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; + {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; + {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; + {_, _} -> S14 + end, + case {PMsg, NMsg} of + {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; + {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; + _ -> S15 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_request/3}). +merge_msg_list_domains_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_domains_response/3}). +merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; + {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; + {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_domain_request/3}). +merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; + {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; + {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). +merge_msg_delete_domain_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_download_image_request/3}). +merge_msg_download_image_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_image_chunk/3}). +merge_msg_image_chunk(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; + {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_get_network_request/3}). +merge_msg_get_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_network/3}). +merge_msg_network(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; + {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; + {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_request/3}). +merge_msg_list_networks_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_networks_response/3}). +merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; + {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; + {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_network_request/3}). +merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; + {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; + {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_network_request/3}). +merge_msg_delete_network_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_timestamp/3}). +merge_msg_timestamp(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; + {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; + {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; + _ -> S2 + end. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); + stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); + get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); + domain -> v_msg_domain(Msg, [MsgName], TrUserData); + list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); + list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); + create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); + delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); + download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); + image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); + get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); + network -> v_msg_network(Msg, [MsgName], TrUserData); + list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); + list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); + create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); + delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_start_domain_request/3}). +-dialyzer({nowarn_function,v_msg_start_domain_request/3}). +v_msg_start_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); +v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_stop_domain_request/3}). +-dialyzer({nowarn_function,v_msg_stop_domain_request/3}). +v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (uuid) -> ok; + (force) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); +v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_domain_request/3}). +-dialyzer({nowarn_function,v_msg_get_domain_request/3}). +v_msg_get_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); +v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_domain/3}). +-dialyzer({nowarn_function,v_msg_domain/3}). +v_msg_domain(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); + _ -> ok + end, + case M of + #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); + _ -> ok + end, + case M of + #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); + _ -> ok + end, + case M of + #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); + _ -> ok + end, + case M of + #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); + _ -> ok + end, + case M of + #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); + _ -> ok + end, + case M of + #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); + _ -> ok + end, + case M of + #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); + _ -> ok + end, + case M of + #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); + _ -> ok + end, + case M of + #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (uuid) -> ok; + (name) -> ok; + (vcpu) -> ok; + (memory) -> ok; + (network) -> ok; + (bridge) -> ok; + (state) -> ok; + (private_ip) -> ok; + (ipv6_address) -> ok; + (user_data) -> ok; + (nested_virtualization) -> ok; + (base_image) -> ok; + (created_at) -> ok; + (os_type) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); +v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_request/3}). +-dialyzer({nowarn_function,v_msg_list_domains_request/3}). +v_msg_list_domains_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); +v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_domains_response/3}). +-dialyzer({nowarn_function,v_msg_list_domains_response/3}). +v_msg_list_domains_response(#{} = M, Path, TrUserData) -> + case M of + #{domains := F1} -> + if is_list(F1) -> + _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) + end; + _ -> ok + end, + lists:foreach(fun (domains) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); +v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_domain_request/3}). +-dialyzer({nowarn_function,v_msg_create_domain_request/3}). +v_msg_create_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); +v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_domain_request/3}). +-dialyzer({nowarn_function,v_msg_delete_domain_request/3}). +v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); +v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_download_image_request/3}). +-dialyzer({nowarn_function,v_msg_download_image_request/3}). +v_msg_download_image_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); +v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_image_chunk/3}). +-dialyzer({nowarn_function,v_msg_image_chunk/3}). +v_msg_image_chunk(#{} = M, Path, TrUserData) -> + case M of + #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (bytes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); +v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). + +-compile({nowarn_unused_function,v_msg_get_network_request/3}). +-dialyzer({nowarn_function,v_msg_get_network_request/3}). +v_msg_get_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); +v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_network/3}). +-dialyzer({nowarn_function,v_msg_network/3}). +v_msg_network(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); + _ -> ok + end, + case M of + #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (name) -> ok; + (cidr) -> ok; + (cidr6) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); +v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_request/3}). +-dialyzer({nowarn_function,v_msg_list_networks_request/3}). +v_msg_list_networks_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); +v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_networks_response/3}). +-dialyzer({nowarn_function,v_msg_list_networks_response/3}). +v_msg_list_networks_response(#{} = M, Path, TrUserData) -> + case M of + #{networks := F1} -> + if is_list(F1) -> + _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) + end; + _ -> ok + end, + lists:foreach(fun (networks) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); +v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_network_request/3}). +-dialyzer({nowarn_function,v_msg_create_network_request/3}). +v_msg_create_network_request(#{} = M, Path, TrUserData) -> + case M of + #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); +v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_network_request/3}). +-dialyzer({nowarn_function,v_msg_delete_network_request/3}). +v_msg_delete_network_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); +v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_msg_timestamp/3}). +-dialyzer({nowarn_function,v_msg_timestamp/3}). +v_msg_timestamp(#{} = M, Path, TrUserData) -> + case M of + #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); + _ -> ok + end, + case M of + #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (seconds) -> ok; + (nanos) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); +v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). + +-compile({nowarn_unused_function,v_type_int32/3}). +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); +v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_int64/3}). +-dialyzer({nowarn_function,v_type_int64/3}). +v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); +v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_uint32/3}). +-dialyzer({nowarn_function,v_type_uint32/3}). +v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; +v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); +v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_uint64/3}). +-dialyzer({nowarn_function,v_type_uint64/3}). +v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; +v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); +v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_bool/3}). +-dialyzer({nowarn_function,v_type_bool/3}). +v_type_bool(false, _Path, _TrUserData) -> ok; +v_type_bool(true, _Path, _TrUserData) -> ok; +v_type_bool(0, _Path, _TrUserData) -> ok; +v_type_bool(1, _Path, _TrUserData) -> ok; +v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,v_type_bytes/3}). +-dialyzer({nowarn_function,v_type_bytes/3}). +v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; +v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, stop_domain_request}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, + {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, domain}, + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, + {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, + {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, network}, + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, + {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, empty}, []}, + {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. + + +get_msg_names() -> + [start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + empty, + timestamp]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> + [start_domain_request, + stop_domain_request, + get_domain_request, + domain, + list_domains_request, + list_domains_response, + create_domain_request, + delete_domain_request, + download_image_request, + image_chunk, + get_network_request, + network, + list_networks_request, + list_networks_response, + create_network_request, + delete_network_request, + empty, + timestamp]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(stop_domain_request) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; +find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(domain) -> + [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, + #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, + #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, + #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, + #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, + #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, + #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, + #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, + #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, + #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, + #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, + #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, + #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; +find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; +find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(network) -> + [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; +find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(empty) -> []; +find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['DomainService']. + + +get_service_def('DomainService') -> + {{service, 'DomainService'}, + [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, + #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; +get_rpc_names(_) -> error. + + +find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; +find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_DomainService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('DomainService') -> <<"DomainService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; +fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; +service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; +service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; +service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; +fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; +fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; +fqbin_to_msg_name(<<"Domain">>) -> domain; +fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; +fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; +fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; +fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; +fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; +fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; +fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; +fqbin_to_msg_name(<<"Network">>) -> network; +fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; +fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; +fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; +fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; +msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; +msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; +msg_name_to_fqbin(domain) -> <<"Domain">>; +msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; +msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; +msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; +msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; +msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; +msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; +msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; +msg_name_to_fqbin(network) -> <<"Network">>; +msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; +msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; +msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; +msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "domain.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["domain.proto", "empty.proto", "timestamp.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["domain", "empty", "timestamp"]. + + +get_msg_containment("domain") -> + [create_domain_request, + create_network_request, + delete_domain_request, + delete_network_request, + domain, + download_image_request, + get_domain_request, + get_network_request, + image_chunk, + list_domains_request, + list_domains_response, + list_networks_request, + list_networks_response, + network, + start_domain_request, + stop_domain_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment("timestamp") -> [timestamp]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("domain") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment("timestamp") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("domain") -> ['DomainService']; +get_service_containment("empty") -> []; +get_service_containment("timestamp") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("domain") -> + [{'DomainService', 'GetDomain'}, + {'DomainService', 'ListDomains'}, + {'DomainService', 'CreateDomain'}, + {'DomainService', 'DeleteDomain'}, + {'DomainService', 'DownloadImage'}, + {'DomainService', 'GetNetwork'}, + {'DomainService', 'ListNetworks'}, + {'DomainService', 'CreateNetwork'}, + {'DomainService', 'DeleteNetwork'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment("timestamp") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("domain") -> []; +get_enum_containment("empty") -> []; +get_enum_containment("timestamp") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; +get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/domain_service_bhvr.erl b/virtuerl/src/pb/domain_service_bhvr.erl new file mode 100644 index 0000000..f01775b --- /dev/null +++ b/virtuerl/src/pb/domain_service_bhvr.erl @@ -0,0 +1,45 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service DomainService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(domain_service_bhvr). + +%% Unary RPC +-callback get_domain(ctx:t(), domain_pb:get_domain_request()) -> + {ok, domain_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_domains(ctx:t(), domain_pb:list_domains_request()) -> + {ok, domain_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_domain(ctx:t(), domain_pb:create_domain_request()) -> + {ok, domain_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_domain(ctx:t(), domain_pb:delete_domain_request()) -> + {ok, domain_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% +-callback download_image(domain_pb:download_image_request(), grpcbox_stream:t()) -> + ok | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_network(ctx:t(), domain_pb:get_network_request()) -> + {ok, domain_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_networks(ctx:t(), domain_pb:list_networks_request()) -> + {ok, domain_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_network(ctx:t(), domain_pb:create_network_request()) -> + {ok, domain_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_network(ctx:t(), domain_pb:delete_network_request()) -> + {ok, domain_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/domain_service_client.erl b/virtuerl/src/pb/domain_service_client.erl new file mode 100644 index 0000000..9162a74 --- /dev/null +++ b/virtuerl/src/pb/domain_service_client.erl @@ -0,0 +1,187 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service DomainService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(domain_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'DomainService'). +-define(PROTO_MODULE, 'domain_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_domain(domain_pb:get_domain_request()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Input) -> + get_domain(ctx:new(), Input, #{}). + +-spec get_domain(ctx:t() | domain_pb:get_domain_request(), domain_pb:get_domain_request() | grpcbox_client:options()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input) when ?is_ctx(Ctx) -> + get_domain(Ctx, Input, #{}); +get_domain(Input, Options) -> + get_domain(ctx:new(), Input, Options). + +-spec get_domain(ctx:t(), domain_pb:get_domain_request(), grpcbox_client:options()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). + +%% @doc Unary RPC +-spec list_domains(domain_pb:list_domains_request()) -> + {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Input) -> + list_domains(ctx:new(), Input, #{}). + +-spec list_domains(ctx:t() | domain_pb:list_domains_request(), domain_pb:list_domains_request() | grpcbox_client:options()) -> + {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input) when ?is_ctx(Ctx) -> + list_domains(Ctx, Input, #{}); +list_domains(Input, Options) -> + list_domains(ctx:new(), Input, Options). + +-spec list_domains(ctx:t(), domain_pb:list_domains_request(), grpcbox_client:options()) -> + {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_domains(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). + +%% @doc Unary RPC +-spec create_domain(domain_pb:create_domain_request()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Input) -> + create_domain(ctx:new(), Input, #{}). + +-spec create_domain(ctx:t() | domain_pb:create_domain_request(), domain_pb:create_domain_request() | grpcbox_client:options()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input) when ?is_ctx(Ctx) -> + create_domain(Ctx, Input, #{}); +create_domain(Input, Options) -> + create_domain(ctx:new(), Input, Options). + +-spec create_domain(ctx:t(), domain_pb:create_domain_request(), grpcbox_client:options()) -> + {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). + +%% @doc Unary RPC +-spec delete_domain(domain_pb:delete_domain_request()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Input) -> + delete_domain(ctx:new(), Input, #{}). + +-spec delete_domain(ctx:t() | domain_pb:delete_domain_request(), domain_pb:delete_domain_request() | grpcbox_client:options()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> + delete_domain(Ctx, Input, #{}); +delete_domain(Input, Options) -> + delete_domain(ctx:new(), Input, Options). + +-spec delete_domain(ctx:t(), domain_pb:delete_domain_request(), grpcbox_client:options()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_domain(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). + +%% @doc +-spec download_image(domain_pb:download_image_request()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Input) -> + download_image(ctx:new(), Input, #{}). + +-spec download_image(ctx:t() | domain_pb:download_image_request(), domain_pb:download_image_request() | grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input) when ?is_ctx(Ctx) -> + download_image(Ctx, Input, #{}); +download_image(Input, Options) -> + download_image(ctx:new(), Input, Options). + +-spec download_image(ctx:t(), domain_pb:download_image_request(), grpcbox_client:options()) -> + {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. +download_image(Ctx, Input, Options) -> + grpcbox_client:stream(Ctx, <<"/DomainService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). + +%% @doc Unary RPC +-spec get_network(domain_pb:get_network_request()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Input) -> + get_network(ctx:new(), Input, #{}). + +-spec get_network(ctx:t() | domain_pb:get_network_request(), domain_pb:get_network_request() | grpcbox_client:options()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input) when ?is_ctx(Ctx) -> + get_network(Ctx, Input, #{}); +get_network(Input, Options) -> + get_network(ctx:new(), Input, Options). + +-spec get_network(ctx:t(), domain_pb:get_network_request(), grpcbox_client:options()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec list_networks(domain_pb:list_networks_request()) -> + {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Input) -> + list_networks(ctx:new(), Input, #{}). + +-spec list_networks(ctx:t() | domain_pb:list_networks_request(), domain_pb:list_networks_request() | grpcbox_client:options()) -> + {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input) when ?is_ctx(Ctx) -> + list_networks(Ctx, Input, #{}); +list_networks(Input, Options) -> + list_networks(ctx:new(), Input, Options). + +-spec list_networks(ctx:t(), domain_pb:list_networks_request(), grpcbox_client:options()) -> + {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_networks(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). + +%% @doc Unary RPC +-spec create_network(domain_pb:create_network_request()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Input) -> + create_network(ctx:new(), Input, #{}). + +-spec create_network(ctx:t() | domain_pb:create_network_request(), domain_pb:create_network_request() | grpcbox_client:options()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input) when ?is_ctx(Ctx) -> + create_network(Ctx, Input, #{}); +create_network(Input, Options) -> + create_network(ctx:new(), Input, Options). + +-spec create_network(ctx:t(), domain_pb:create_network_request(), grpcbox_client:options()) -> + {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). + +%% @doc Unary RPC +-spec delete_network(domain_pb:delete_network_request()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Input) -> + delete_network(ctx:new(), Input, #{}). + +-spec delete_network(ctx:t() | domain_pb:delete_network_request(), domain_pb:delete_network_request() | grpcbox_client:options()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input) when ?is_ctx(Ctx) -> + delete_network(Ctx, Input, #{}); +delete_network(Input, Options) -> + delete_network(ctx:new(), Input, Options). + +-spec delete_network(ctx:t(), domain_pb:delete_network_request(), grpcbox_client:options()) -> + {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_network(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/DomainService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). + diff --git a/virtuerl/src/pb/host_pb.erl b/virtuerl/src/pb/host_pb.erl new file mode 100644 index 0000000..994eb97 --- /dev/null +++ b/virtuerl/src/pb/host_pb.erl @@ -0,0 +1,1431 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(host_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type create_bootstrap_token_request() :: + #{expires_at => unicode:chardata() % = 1, optional + }. + +-type create_bootstrap_token_response() :: + #{token => unicode:chardata() % = 1, optional + }. + +-type host() :: + #{name => unicode:chardata(), % = 1, optional + address => unicode:chardata() % = 2, optional + }. + +-type list_hosts_request() :: + #{ + }. + +-type list_hosts_response() :: + #{hosts => [host()] % = 1, repeated + }. + +-type register_host_request() :: + #{host => host(), % = 1, optional + token => unicode:chardata() % = 2, optional + }. + +-type heartbeat_request() :: + #{host => host() % = 1, optional + }. + +-type heartbeat_response() :: + #{ + }. + +-type empty() :: + #{ + }. + +-export_type(['create_bootstrap_token_request'/0, 'create_bootstrap_token_response'/0, 'host'/0, 'list_hosts_request'/0, 'list_hosts_response'/0, 'register_host_request'/0, 'heartbeat_request'/0, 'heartbeat_response'/0, 'empty'/0]). +-type '$msg_name'() :: create_bootstrap_token_request | create_bootstrap_token_response | host | list_hosts_request | list_hosts_response | register_host_request | heartbeat_request | heartbeat_response | empty. +-type '$msg'() :: create_bootstrap_token_request() | create_bootstrap_token_response() | host() | list_hosts_request() | list_hosts_response() | register_host_request() | heartbeat_request() | heartbeat_response() | empty(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + create_bootstrap_token_request -> encode_msg_create_bootstrap_token_request(id(Msg, TrUserData), TrUserData); + create_bootstrap_token_response -> encode_msg_create_bootstrap_token_response(id(Msg, TrUserData), TrUserData); + host -> encode_msg_host(id(Msg, TrUserData), TrUserData); + list_hosts_request -> encode_msg_list_hosts_request(id(Msg, TrUserData), TrUserData); + list_hosts_response -> encode_msg_list_hosts_response(id(Msg, TrUserData), TrUserData); + register_host_request -> encode_msg_register_host_request(id(Msg, TrUserData), TrUserData); + heartbeat_request -> encode_msg_heartbeat_request(id(Msg, TrUserData), TrUserData); + heartbeat_response -> encode_msg_heartbeat_response(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_create_bootstrap_token_request(Msg, TrUserData) -> encode_msg_create_bootstrap_token_request(Msg, <<>>, TrUserData). + + +encode_msg_create_bootstrap_token_request(#{} = M, Bin, TrUserData) -> + case M of + #{expires_at := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_create_bootstrap_token_response(Msg, TrUserData) -> encode_msg_create_bootstrap_token_response(Msg, <<>>, TrUserData). + + +encode_msg_create_bootstrap_token_response(#{} = M, Bin, TrUserData) -> + case M of + #{token := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_host(Msg, TrUserData) -> encode_msg_host(Msg, <<>>, TrUserData). + + +encode_msg_host(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{address := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_list_hosts_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_list_hosts_response(Msg, TrUserData) -> encode_msg_list_hosts_response(Msg, <<>>, TrUserData). + + +encode_msg_list_hosts_response(#{} = M, Bin, TrUserData) -> + case M of + #{hosts := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_hosts_response_hosts(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_register_host_request(Msg, TrUserData) -> encode_msg_register_host_request(Msg, <<>>, TrUserData). + + +encode_msg_register_host_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_register_host_request_host(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{token := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_heartbeat_request(Msg, TrUserData) -> encode_msg_heartbeat_request(Msg, <<>>, TrUserData). + + +encode_msg_heartbeat_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_heartbeat_request_host(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_heartbeat_response(_Msg, _TrUserData) -> <<>>. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +e_mfield_list_hosts_response_hosts(Msg, Bin, TrUserData) -> + SubBin = encode_msg_host(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_hosts_response_hosts([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_hosts_response_hosts(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_hosts_response_hosts(Rest, Bin3, TrUserData); +e_field_list_hosts_response_hosts([], Bin, _TrUserData) -> Bin. + +e_mfield_register_host_request_host(Msg, Bin, TrUserData) -> + SubBin = encode_msg_host(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_heartbeat_request_host(Msg, Bin, TrUserData) -> + SubBin = encode_msg_host(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(create_bootstrap_token_request, Bin, TrUserData) -> id(decode_msg_create_bootstrap_token_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_bootstrap_token_response, Bin, TrUserData) -> id(decode_msg_create_bootstrap_token_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(host, Bin, TrUserData) -> id(decode_msg_host(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_hosts_request, Bin, TrUserData) -> id(decode_msg_list_hosts_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_hosts_response, Bin, TrUserData) -> id(decode_msg_list_hosts_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(register_host_request, Bin, TrUserData) -> id(decode_msg_register_host_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(heartbeat_request, Bin, TrUserData) -> id(decode_msg_heartbeat_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(heartbeat_response, Bin, TrUserData) -> id(decode_msg_heartbeat_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). + + + +decode_msg_create_bootstrap_token_request(Bin, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_bootstrap_token_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_bootstrap_token_request_expires_at(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_create_bootstrap_token_request(<<>>, 0, 0, _, F@_1, _) -> #{expires_at => F@_1}; +dfp_read_field_def_create_bootstrap_token_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_bootstrap_token_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_create_bootstrap_token_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_bootstrap_token_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_create_bootstrap_token_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_bootstrap_token_request_expires_at(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_create_bootstrap_token_request(<<>>, 0, 0, _, F@_1, _) -> #{expires_at => F@_1}. + +d_field_create_bootstrap_token_request_expires_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_bootstrap_token_request_expires_at(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_create_bootstrap_token_request_expires_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_bootstrap_token_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_create_bootstrap_token_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_create_bootstrap_token_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_create_bootstrap_token_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_bootstrap_token_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_create_bootstrap_token_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_bootstrap_token_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_create_bootstrap_token_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_bootstrap_token_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_create_bootstrap_token_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_create_bootstrap_token_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_bootstrap_token_response(Bin, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_bootstrap_token_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_bootstrap_token_response_token(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_create_bootstrap_token_response(<<>>, 0, 0, _, F@_1, _) -> #{token => F@_1}; +dfp_read_field_def_create_bootstrap_token_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_bootstrap_token_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_create_bootstrap_token_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_bootstrap_token_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_create_bootstrap_token_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_bootstrap_token_response_token(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_create_bootstrap_token_response(<<>>, 0, 0, _, F@_1, _) -> #{token => F@_1}. + +d_field_create_bootstrap_token_response_token(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_bootstrap_token_response_token(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_create_bootstrap_token_response_token(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_bootstrap_token_response(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_create_bootstrap_token_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_create_bootstrap_token_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_create_bootstrap_token_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_bootstrap_token_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_create_bootstrap_token_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_bootstrap_token_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_create_bootstrap_token_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_bootstrap_token_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_create_bootstrap_token_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_create_bootstrap_token_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_host(Bin, TrUserData) -> dfp_read_field_def_host(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_host(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_host_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_host(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_host_address(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_host(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, address => F@_2}; +dfp_read_field_def_host(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_host(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_host(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_host_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_host_address(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_host(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, address => F@_2}. + +d_field_host_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_host_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_host_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_host(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_host_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_host_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_host_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_host(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_host(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_host(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_host(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_host(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_host(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_host(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_host(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_list_hosts_request(Bin, TrUserData) -> dfp_read_field_def_list_hosts_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_list_hosts_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_list_hosts_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_hosts_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_list_hosts_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_hosts_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_list_hosts_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_list_hosts_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_list_hosts_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_hosts_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_list_hosts_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_list_hosts_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_hosts_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_list_hosts_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_hosts_request(Rest2, 0, 0, F, TrUserData). + +skip_group_list_hosts_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_hosts_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_list_hosts_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_list_hosts_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_list_hosts_response(Bin, TrUserData) -> dfp_read_field_def_list_hosts_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_hosts_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_hosts_response_hosts(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_hosts_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{hosts => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_hosts_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_hosts_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_hosts_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_hosts_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_hosts_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_hosts_response_hosts(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_hosts_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{hosts => lists_reverse(R1, TrUserData)} + end. + +d_field_list_hosts_response_hosts(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_hosts_response_hosts(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_hosts_response_hosts(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_hosts_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_hosts_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_hosts_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_hosts_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_hosts_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_hosts_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_hosts_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_hosts_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_hosts_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_hosts_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_hosts_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_register_host_request(Bin, TrUserData) -> dfp_read_field_def_register_host_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_register_host_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_register_host_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_register_host_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_register_host_request_token(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_register_host_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{token => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{host => F@_1} + end; +dfp_read_field_def_register_host_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_register_host_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_register_host_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_register_host_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_register_host_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_register_host_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_register_host_request_token(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_register_host_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{token => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{host => F@_1} + end. + +d_field_register_host_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_register_host_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_register_host_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_register_host_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_host(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_register_host_request_token(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_register_host_request_token(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_register_host_request_token(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_register_host_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_register_host_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_register_host_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_register_host_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_register_host_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_register_host_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_register_host_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_register_host_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_register_host_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_register_host_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_register_host_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_heartbeat_request(Bin, TrUserData) -> dfp_read_field_def_heartbeat_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_heartbeat_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_heartbeat_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_heartbeat_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{host => F@_1} + end; +dfp_read_field_def_heartbeat_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_heartbeat_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_heartbeat_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_heartbeat_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_heartbeat_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_heartbeat_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_heartbeat_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{host => F@_1} + end. + +d_field_heartbeat_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_heartbeat_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_heartbeat_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_heartbeat_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_host(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_heartbeat_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_heartbeat_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_heartbeat_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_heartbeat_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_heartbeat_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_heartbeat_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_heartbeat_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_heartbeat_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_heartbeat_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_heartbeat_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_heartbeat_response(Bin, TrUserData) -> dfp_read_field_def_heartbeat_response(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_heartbeat_response(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_heartbeat_response(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_heartbeat_response(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_heartbeat_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_heartbeat_response(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_heartbeat_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_heartbeat_response(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_heartbeat_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_heartbeat_response(Rest, Z1, Z2, F, TrUserData); +skip_varint_heartbeat_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_heartbeat_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_heartbeat_response(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_heartbeat_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_heartbeat_response(Rest2, 0, 0, F, TrUserData). + +skip_group_heartbeat_response(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_heartbeat_response(Rest, 0, Z2, FNum, TrUserData). + +skip_32_heartbeat_response(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). + +skip_64_heartbeat_response(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + create_bootstrap_token_request -> merge_msg_create_bootstrap_token_request(Prev, New, TrUserData); + create_bootstrap_token_response -> merge_msg_create_bootstrap_token_response(Prev, New, TrUserData); + host -> merge_msg_host(Prev, New, TrUserData); + list_hosts_request -> merge_msg_list_hosts_request(Prev, New, TrUserData); + list_hosts_response -> merge_msg_list_hosts_response(Prev, New, TrUserData); + register_host_request -> merge_msg_register_host_request(Prev, New, TrUserData); + heartbeat_request -> merge_msg_heartbeat_request(Prev, New, TrUserData); + heartbeat_response -> merge_msg_heartbeat_response(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_create_bootstrap_token_request/3}). +merge_msg_create_bootstrap_token_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{expires_at := NFexpires_at}} -> S1#{expires_at => NFexpires_at}; + {#{expires_at := PFexpires_at}, _} -> S1#{expires_at => PFexpires_at}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_bootstrap_token_response/3}). +merge_msg_create_bootstrap_token_response(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{token := NFtoken}} -> S1#{token => NFtoken}; + {#{token := PFtoken}, _} -> S1#{token => PFtoken}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_host/3}). +merge_msg_host(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S1#{name => NFname}; + {#{name := PFname}, _} -> S1#{name => PFname}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{address := NFaddress}} -> S2#{address => NFaddress}; + {#{address := PFaddress}, _} -> S2#{address => PFaddress}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_list_hosts_request/3}). +merge_msg_list_hosts_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_list_hosts_response/3}). +merge_msg_list_hosts_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{hosts := PFhosts}, #{hosts := NFhosts}} -> S1#{hosts => 'erlang_++'(PFhosts, NFhosts, TrUserData)}; + {_, #{hosts := NFhosts}} -> S1#{hosts => NFhosts}; + {#{hosts := PFhosts}, _} -> S1#{hosts => PFhosts}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_register_host_request/3}). +merge_msg_register_host_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{host := PFhost}, #{host := NFhost}} -> S1#{host => merge_msg_host(PFhost, NFhost, TrUserData)}; + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{token := NFtoken}} -> S2#{token => NFtoken}; + {#{token := PFtoken}, _} -> S2#{token => PFtoken}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_heartbeat_request/3}). +merge_msg_heartbeat_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{host := PFhost}, #{host := NFhost}} -> S1#{host => merge_msg_host(PFhost, NFhost, TrUserData)}; + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_heartbeat_response/3}). +merge_msg_heartbeat_response(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + create_bootstrap_token_request -> v_msg_create_bootstrap_token_request(Msg, [MsgName], TrUserData); + create_bootstrap_token_response -> v_msg_create_bootstrap_token_response(Msg, [MsgName], TrUserData); + host -> v_msg_host(Msg, [MsgName], TrUserData); + list_hosts_request -> v_msg_list_hosts_request(Msg, [MsgName], TrUserData); + list_hosts_response -> v_msg_list_hosts_response(Msg, [MsgName], TrUserData); + register_host_request -> v_msg_register_host_request(Msg, [MsgName], TrUserData); + heartbeat_request -> v_msg_heartbeat_request(Msg, [MsgName], TrUserData); + heartbeat_response -> v_msg_heartbeat_response(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_create_bootstrap_token_request/3}). +-dialyzer({nowarn_function,v_msg_create_bootstrap_token_request/3}). +v_msg_create_bootstrap_token_request(#{} = M, Path, TrUserData) -> + case M of + #{expires_at := F1} -> v_type_string(F1, [expires_at | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (expires_at) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_bootstrap_token_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_bootstrap_token_request}, M, Path); +v_msg_create_bootstrap_token_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_bootstrap_token_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_bootstrap_token_response/3}). +-dialyzer({nowarn_function,v_msg_create_bootstrap_token_response/3}). +v_msg_create_bootstrap_token_response(#{} = M, Path, TrUserData) -> + case M of + #{token := F1} -> v_type_string(F1, [token | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (token) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_bootstrap_token_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_bootstrap_token_response}, M, Path); +v_msg_create_bootstrap_token_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_bootstrap_token_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_host/3}). +-dialyzer({nowarn_function,v_msg_host/3}). +v_msg_host(#{} = M, Path, TrUserData) -> + case M of + #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{address := F2} -> v_type_string(F2, [address | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (name) -> ok; + (address) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_host(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), host}, M, Path); +v_msg_host(X, Path, _TrUserData) -> mk_type_error({expected_msg, host}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_hosts_request/3}). +-dialyzer({nowarn_function,v_msg_list_hosts_request/3}). +v_msg_list_hosts_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_list_hosts_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_hosts_request}, M, Path); +v_msg_list_hosts_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_hosts_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_hosts_response/3}). +-dialyzer({nowarn_function,v_msg_list_hosts_response/3}). +v_msg_list_hosts_response(#{} = M, Path, TrUserData) -> + case M of + #{hosts := F1} -> + if is_list(F1) -> + _ = [v_msg_host(Elem, [hosts | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, host}}, F1, [hosts | Path]) + end; + _ -> ok + end, + lists:foreach(fun (hosts) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_hosts_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_hosts_response}, M, Path); +v_msg_list_hosts_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_hosts_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_register_host_request/3}). +-dialyzer({nowarn_function,v_msg_register_host_request/3}). +v_msg_register_host_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_msg_host(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{token := F2} -> v_type_string(F2, [token | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (token) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_register_host_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), register_host_request}, M, Path); +v_msg_register_host_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, register_host_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_heartbeat_request/3}). +-dialyzer({nowarn_function,v_msg_heartbeat_request/3}). +v_msg_heartbeat_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_msg_host(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_heartbeat_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), heartbeat_request}, M, Path); +v_msg_heartbeat_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, heartbeat_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_heartbeat_response/3}). +-dialyzer({nowarn_function,v_msg_heartbeat_response/3}). +v_msg_heartbeat_response(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_heartbeat_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), heartbeat_response}, M, Path); +v_msg_heartbeat_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, heartbeat_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, create_bootstrap_token_request}, [#{name => expires_at, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, create_bootstrap_token_response}, [#{name => token, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, host}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => address, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, list_hosts_request}, []}, + {{msg, list_hosts_response}, [#{name => hosts, fnum => 1, rnum => 2, type => {msg, host}, occurrence => repeated, opts => []}]}, + {{msg, register_host_request}, [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}, #{name => token, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, heartbeat_request}, [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}]}, + {{msg, heartbeat_response}, []}, + {{msg, empty}, []}]. + + +get_msg_names() -> [create_bootstrap_token_request, create_bootstrap_token_response, host, list_hosts_request, list_hosts_response, register_host_request, heartbeat_request, heartbeat_response, empty]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> [create_bootstrap_token_request, create_bootstrap_token_response, host, list_hosts_request, list_hosts_response, register_host_request, heartbeat_request, heartbeat_response, empty]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(create_bootstrap_token_request) -> [#{name => expires_at, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(create_bootstrap_token_response) -> [#{name => token, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(host) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => address, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_hosts_request) -> []; +find_msg_def(list_hosts_response) -> [#{name => hosts, fnum => 1, rnum => 2, type => {msg, host}, occurrence => repeated, opts => []}]; +find_msg_def(register_host_request) -> [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}, #{name => token, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(heartbeat_request) -> [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}]; +find_msg_def(heartbeat_response) -> []; +find_msg_def(empty) -> []; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['HostService']. + + +get_service_def('HostService') -> + {{service, 'HostService'}, + [#{name => 'CreateBootstrapToken', input => create_bootstrap_token_request, output => create_bootstrap_token_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetHost', input => host, output => host, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListHosts', input => list_hosts_request, output => list_hosts_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'Register', input => register_host_request, output => host, input_stream => false, output_stream => false, opts => []}, + #{name => 'Deregister', input => host, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'Heartbeat', input => heartbeat_request, output => heartbeat_response, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('HostService') -> ['CreateBootstrapToken', 'GetHost', 'ListHosts', 'Register', 'Deregister', 'Heartbeat']; +get_rpc_names(_) -> error. + + +find_rpc_def('HostService', RpcName) -> find_rpc_def_HostService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_HostService('CreateBootstrapToken') -> #{name => 'CreateBootstrapToken', input => create_bootstrap_token_request, output => create_bootstrap_token_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService('GetHost') -> #{name => 'GetHost', input => host, output => host, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService('ListHosts') -> #{name => 'ListHosts', input => list_hosts_request, output => list_hosts_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService('Register') -> #{name => 'Register', input => register_host_request, output => host, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService('Deregister') -> #{name => 'Deregister', input => host, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService('Heartbeat') -> #{name => 'Heartbeat', input => heartbeat_request, output => heartbeat_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_HostService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"HostService">>) -> 'HostService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('HostService') -> <<"HostService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"CreateBootstrapToken">>) -> {'HostService', 'CreateBootstrapToken'}; +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"GetHost">>) -> {'HostService', 'GetHost'}; +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"ListHosts">>) -> {'HostService', 'ListHosts'}; +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Register">>) -> {'HostService', 'Register'}; +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Deregister">>) -> {'HostService', 'Deregister'}; +fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Heartbeat">>) -> {'HostService', 'Heartbeat'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('HostService', 'CreateBootstrapToken') -> {<<"HostService">>, <<"CreateBootstrapToken">>}; +service_and_rpc_name_to_fqbins('HostService', 'GetHost') -> {<<"HostService">>, <<"GetHost">>}; +service_and_rpc_name_to_fqbins('HostService', 'ListHosts') -> {<<"HostService">>, <<"ListHosts">>}; +service_and_rpc_name_to_fqbins('HostService', 'Register') -> {<<"HostService">>, <<"Register">>}; +service_and_rpc_name_to_fqbins('HostService', 'Deregister') -> {<<"HostService">>, <<"Deregister">>}; +service_and_rpc_name_to_fqbins('HostService', 'Heartbeat') -> {<<"HostService">>, <<"Heartbeat">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"CreateBootstrapTokenRequest">>) -> create_bootstrap_token_request; +fqbin_to_msg_name(<<"CreateBootstrapTokenResponse">>) -> create_bootstrap_token_response; +fqbin_to_msg_name(<<"Host">>) -> host; +fqbin_to_msg_name(<<"ListHostsRequest">>) -> list_hosts_request; +fqbin_to_msg_name(<<"ListHostsResponse">>) -> list_hosts_response; +fqbin_to_msg_name(<<"RegisterHostRequest">>) -> register_host_request; +fqbin_to_msg_name(<<"HeartbeatRequest">>) -> heartbeat_request; +fqbin_to_msg_name(<<"HeartbeatResponse">>) -> heartbeat_response; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(create_bootstrap_token_request) -> <<"CreateBootstrapTokenRequest">>; +msg_name_to_fqbin(create_bootstrap_token_response) -> <<"CreateBootstrapTokenResponse">>; +msg_name_to_fqbin(host) -> <<"Host">>; +msg_name_to_fqbin(list_hosts_request) -> <<"ListHostsRequest">>; +msg_name_to_fqbin(list_hosts_response) -> <<"ListHostsResponse">>; +msg_name_to_fqbin(register_host_request) -> <<"RegisterHostRequest">>; +msg_name_to_fqbin(heartbeat_request) -> <<"HeartbeatRequest">>; +msg_name_to_fqbin(heartbeat_response) -> <<"HeartbeatResponse">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "host.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["host.proto", "empty.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["host", "empty"]. + + +get_msg_containment("host") -> [create_bootstrap_token_request, create_bootstrap_token_response, heartbeat_request, heartbeat_response, host, list_hosts_request, list_hosts_response, register_host_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("host") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("host") -> ['HostService']; +get_service_containment("empty") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("host") -> [{'HostService', 'CreateBootstrapToken'}, {'HostService', 'GetHost'}, {'HostService', 'ListHosts'}, {'HostService', 'Register'}, {'HostService', 'Deregister'}, {'HostService', 'Heartbeat'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("host") -> []; +get_enum_containment("empty") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"RegisterHostRequest">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"ListHostsRequest">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"Host">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"HeartbeatRequest">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"CreateBootstrapTokenRequest">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"ListHostsResponse">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"HeartbeatResponse">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"CreateBootstrapTokenResponse">>) -> "host"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"HostService">>) -> "host"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/host_service_bhvr.erl b/virtuerl/src/pb/host_service_bhvr.erl new file mode 100644 index 0000000..afefefd --- /dev/null +++ b/virtuerl/src/pb/host_service_bhvr.erl @@ -0,0 +1,33 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service HostService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(host_service_bhvr). + +%% Unary RPC +-callback create_bootstrap_token(ctx:t(), host_pb:create_bootstrap_token_request()) -> + {ok, host_pb:create_bootstrap_token_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_host(ctx:t(), host_pb:host()) -> + {ok, host_pb:host(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_hosts(ctx:t(), host_pb:list_hosts_request()) -> + {ok, host_pb:list_hosts_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback register(ctx:t(), host_pb:register_host_request()) -> + {ok, host_pb:host(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback deregister(ctx:t(), host_pb:host()) -> + {ok, host_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback heartbeat(ctx:t(), host_pb:heartbeat_request()) -> + {ok, host_pb:heartbeat_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/host_service_client.erl b/virtuerl/src/pb/host_service_client.erl new file mode 100644 index 0000000..3ac13f9 --- /dev/null +++ b/virtuerl/src/pb/host_service_client.erl @@ -0,0 +1,133 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service HostService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(host_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'HostService'). +-define(PROTO_MODULE, 'host_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec create_bootstrap_token(host_pb:create_bootstrap_token_request()) -> + {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_bootstrap_token(Input) -> + create_bootstrap_token(ctx:new(), Input, #{}). + +-spec create_bootstrap_token(ctx:t() | host_pb:create_bootstrap_token_request(), host_pb:create_bootstrap_token_request() | grpcbox_client:options()) -> + {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_bootstrap_token(Ctx, Input) when ?is_ctx(Ctx) -> + create_bootstrap_token(Ctx, Input, #{}); +create_bootstrap_token(Input, Options) -> + create_bootstrap_token(ctx:new(), Input, Options). + +-spec create_bootstrap_token(ctx:t(), host_pb:create_bootstrap_token_request(), grpcbox_client:options()) -> + {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_bootstrap_token(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/CreateBootstrapToken">>, Input, ?DEF(create_bootstrap_token_request, create_bootstrap_token_response, <<"CreateBootstrapTokenRequest">>), Options). + +%% @doc Unary RPC +-spec get_host(host_pb:host()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_host(Input) -> + get_host(ctx:new(), Input, #{}). + +-spec get_host(ctx:t() | host_pb:host(), host_pb:host() | grpcbox_client:options()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_host(Ctx, Input) when ?is_ctx(Ctx) -> + get_host(Ctx, Input, #{}); +get_host(Input, Options) -> + get_host(ctx:new(), Input, Options). + +-spec get_host(ctx:t(), host_pb:host(), grpcbox_client:options()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_host(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/GetHost">>, Input, ?DEF(host, host, <<"Host">>), Options). + +%% @doc Unary RPC +-spec list_hosts(host_pb:list_hosts_request()) -> + {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_hosts(Input) -> + list_hosts(ctx:new(), Input, #{}). + +-spec list_hosts(ctx:t() | host_pb:list_hosts_request(), host_pb:list_hosts_request() | grpcbox_client:options()) -> + {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_hosts(Ctx, Input) when ?is_ctx(Ctx) -> + list_hosts(Ctx, Input, #{}); +list_hosts(Input, Options) -> + list_hosts(ctx:new(), Input, Options). + +-spec list_hosts(ctx:t(), host_pb:list_hosts_request(), grpcbox_client:options()) -> + {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_hosts(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/ListHosts">>, Input, ?DEF(list_hosts_request, list_hosts_response, <<"ListHostsRequest">>), Options). + +%% @doc Unary RPC +-spec register(host_pb:register_host_request()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +register(Input) -> + register(ctx:new(), Input, #{}). + +-spec register(ctx:t() | host_pb:register_host_request(), host_pb:register_host_request() | grpcbox_client:options()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +register(Ctx, Input) when ?is_ctx(Ctx) -> + register(Ctx, Input, #{}); +register(Input, Options) -> + register(ctx:new(), Input, Options). + +-spec register(ctx:t(), host_pb:register_host_request(), grpcbox_client:options()) -> + {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +register(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/Register">>, Input, ?DEF(register_host_request, host, <<"RegisterHostRequest">>), Options). + +%% @doc Unary RPC +-spec deregister(host_pb:host()) -> + {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +deregister(Input) -> + deregister(ctx:new(), Input, #{}). + +-spec deregister(ctx:t() | host_pb:host(), host_pb:host() | grpcbox_client:options()) -> + {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +deregister(Ctx, Input) when ?is_ctx(Ctx) -> + deregister(Ctx, Input, #{}); +deregister(Input, Options) -> + deregister(ctx:new(), Input, Options). + +-spec deregister(ctx:t(), host_pb:host(), grpcbox_client:options()) -> + {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +deregister(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/Deregister">>, Input, ?DEF(host, empty, <<"Host">>), Options). + +%% @doc Unary RPC +-spec heartbeat(host_pb:heartbeat_request()) -> + {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +heartbeat(Input) -> + heartbeat(ctx:new(), Input, #{}). + +-spec heartbeat(ctx:t() | host_pb:heartbeat_request(), host_pb:heartbeat_request() | grpcbox_client:options()) -> + {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +heartbeat(Ctx, Input) when ?is_ctx(Ctx) -> + heartbeat(Ctx, Input, #{}); +heartbeat(Input, Options) -> + heartbeat(ctx:new(), Input, Options). + +-spec heartbeat(ctx:t(), host_pb:heartbeat_request(), grpcbox_client:options()) -> + {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +heartbeat(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/HostService/Heartbeat">>, Input, ?DEF(heartbeat_request, heartbeat_response, <<"HeartbeatRequest">>), Options). + diff --git a/virtuerl/src/pb/port_forwarding_pb.erl b/virtuerl/src/pb/port_forwarding_pb.erl new file mode 100644 index 0000000..f36a103 --- /dev/null +++ b/virtuerl/src/pb/port_forwarding_pb.erl @@ -0,0 +1,1320 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(port_forwarding_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type port_forwarding_identifier() :: + #{host => unicode:chardata(), % = 1, optional + protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer() % = 3, optional, 32 bits + }. + +-type port_forwarding() :: + #{protocol => unicode:chardata(), % = 2, optional + source_port => non_neg_integer(), % = 3, optional, 32 bits + target_ip => unicode:chardata(), % = 4, optional + target_port => non_neg_integer() % = 5, optional, 32 bits + }. + +-type list_port_forwardings_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_port_forwardings_response() :: + #{port_forwardings => [port_forwarding()] % = 1, repeated + }. + +-type put_port_forwarding_request() :: + #{port_forwarding => port_forwarding(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type empty() :: + #{ + }. + +-export_type(['port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'empty'/0]). +-type '$msg_name'() :: port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | empty. +-type '$msg'() :: port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | empty(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); + port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); + list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); + list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); + put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{protocol := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{source_port := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). + + +encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{protocol := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{source_port := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_varint(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + B3 = case M of + #{target_ip := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end, + case M of + #{target_port := F4} -> + begin + TrF4 = id(F4, TrUserData), + if TrF4 =:= 0 -> B3; + true -> e_varint(TrF4, <>, TrUserData) + end + end; + _ -> B3 + end. + +encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). + + +encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> + case M of + #{port_forwardings := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). + + +encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{port_forwarding := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); +e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. + +e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> + SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). + + + +decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; +dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. + +d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; +dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); + 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) + end + end; +dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. + +d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). + +d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). + +d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). + +skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); +skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). + +decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} + end. + +d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end; +dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{port_forwarding => F@_1} + end. + +d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); + port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); + list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); + list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); + put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). +merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_port_forwarding/3}). +merge_msg_port_forwarding(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; + {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; + {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; + _ -> S2 + end, + S4 = case {PMsg, NMsg} of + {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; + {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; + _ -> S3 + end, + case {PMsg, NMsg} of + {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; + {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; + _ -> S4 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). +merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). +merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; + {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; + {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). +merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; + {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; + {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); + port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); + list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); + list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); + put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). +v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (protocol) -> ok; + (source_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); +v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_port_forwarding/3}). +-dialyzer({nowarn_function,v_msg_port_forwarding/3}). +v_msg_port_forwarding(#{} = M, Path, TrUserData) -> + case M of + #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); + _ -> ok + end, + case M of + #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); + _ -> ok + end, + case M of + #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); + _ -> ok + end, + case M of + #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (protocol) -> ok; + (source_port) -> ok; + (target_ip) -> ok; + (target_port) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); +v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). +v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); +v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). +-dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). +v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> + case M of + #{port_forwardings := F1} -> + if is_list(F1) -> + _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) + end; + _ -> ok + end, + lists:foreach(fun (port_forwardings) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); +v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). +-dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). +v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> + case M of + #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (port_forwarding) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); +v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_type_uint32/3}). +-dialyzer({nowarn_function,v_type_uint32/3}). +v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; +v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); +v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, port_forwarding_identifier}, + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, + {{msg, port_forwarding}, + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, + {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, empty}, []}]. + + +get_msg_names() -> [port_forwarding_identifier, port_forwarding, list_port_forwardings_request, list_port_forwardings_response, put_port_forwarding_request, empty]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> [port_forwarding_identifier, port_forwarding, list_port_forwardings_request, list_port_forwardings_response, put_port_forwarding_request, empty]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(port_forwarding_identifier) -> + [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(port_forwarding) -> + [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, + #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; +find_msg_def(put_port_forwarding_request) -> + [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(empty) -> []; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['PortForwardingService']. + + +get_service_def('PortForwardingService') -> + {{service, 'PortForwardingService'}, + [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; +get_rpc_names(_) -> error. + + +find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_PortForwardingService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; +fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; +service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; +fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; +fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; +fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; +fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; +msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; +msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; +msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; +msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "port_forwarding.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["port_forwarding.proto", "empty.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["port_forwarding", "empty"]. + + +get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("port_forwarding") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("port_forwarding") -> ['PortForwardingService']; +get_service_containment("empty") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("port_forwarding") -> []; +get_enum_containment("empty") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/port_forwarding_service_bhvr.erl b/virtuerl/src/pb/port_forwarding_service_bhvr.erl new file mode 100644 index 0000000..21208cf --- /dev/null +++ b/virtuerl/src/pb/port_forwarding_service_bhvr.erl @@ -0,0 +1,25 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service PortForwardingService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(port_forwarding_service_bhvr). + +%% Unary RPC +-callback get_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier()) -> + {ok, port_forwarding_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_port_forwardings(ctx:t(), port_forwarding_pb:list_port_forwardings_request()) -> + {ok, port_forwarding_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_port_forwarding(ctx:t(), port_forwarding_pb:put_port_forwarding_request()) -> + {ok, port_forwarding_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier()) -> + {ok, port_forwarding_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/port_forwarding_service_client.erl b/virtuerl/src/pb/port_forwarding_service_client.erl new file mode 100644 index 0000000..6043ffa --- /dev/null +++ b/virtuerl/src/pb/port_forwarding_service_client.erl @@ -0,0 +1,97 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service PortForwardingService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(port_forwarding_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'PortForwardingService'). +-define(PROTO_MODULE, 'port_forwarding_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_port_forwarding(port_forwarding_pb:port_forwarding_identifier()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Input) -> + get_port_forwarding(ctx:new(), Input, #{}). + +-spec get_port_forwarding(ctx:t() | port_forwarding_pb:port_forwarding_identifier(), port_forwarding_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + get_port_forwarding(Ctx, Input, #{}); +get_port_forwarding(Input, Options) -> + get_port_forwarding(ctx:new(), Input, Options). + +-spec get_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/PortForwardingService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_port_forwardings(port_forwarding_pb:list_port_forwardings_request()) -> + {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Input) -> + list_port_forwardings(ctx:new(), Input, #{}). + +-spec list_port_forwardings(ctx:t() | port_forwarding_pb:list_port_forwardings_request(), port_forwarding_pb:list_port_forwardings_request() | grpcbox_client:options()) -> + {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> + list_port_forwardings(Ctx, Input, #{}); +list_port_forwardings(Input, Options) -> + list_port_forwardings(ctx:new(), Input, Options). + +-spec list_port_forwardings(ctx:t(), port_forwarding_pb:list_port_forwardings_request(), grpcbox_client:options()) -> + {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_port_forwardings(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/PortForwardingService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). + +%% @doc Unary RPC +-spec put_port_forwarding(port_forwarding_pb:put_port_forwarding_request()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Input) -> + put_port_forwarding(ctx:new(), Input, #{}). + +-spec put_port_forwarding(ctx:t() | port_forwarding_pb:put_port_forwarding_request(), port_forwarding_pb:put_port_forwarding_request() | grpcbox_client:options()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + put_port_forwarding(Ctx, Input, #{}); +put_port_forwarding(Input, Options) -> + put_port_forwarding(ctx:new(), Input, Options). + +-spec put_port_forwarding(ctx:t(), port_forwarding_pb:put_port_forwarding_request(), grpcbox_client:options()) -> + {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/PortForwardingService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). + +%% @doc Unary RPC +-spec delete_port_forwarding(port_forwarding_pb:port_forwarding_identifier()) -> + {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Input) -> + delete_port_forwarding(ctx:new(), Input, #{}). + +-spec delete_port_forwarding(ctx:t() | port_forwarding_pb:port_forwarding_identifier(), port_forwarding_pb:port_forwarding_identifier() | grpcbox_client:options()) -> + {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> + delete_port_forwarding(Ctx, Input, #{}); +delete_port_forwarding(Input, Options) -> + delete_port_forwarding(ctx:new(), Input, Options). + +-spec delete_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier(), grpcbox_client:options()) -> + {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_port_forwarding(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/PortForwardingService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). + diff --git a/virtuerl/src/pb/route_pb.erl b/virtuerl/src/pb/route_pb.erl new file mode 100644 index 0000000..c2c47f4 --- /dev/null +++ b/virtuerl/src/pb/route_pb.erl @@ -0,0 +1,1912 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(route_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type route_table() :: + #{network_name => unicode:chardata(), % = 1, optional + id => non_neg_integer(), % = 2, optional, 32 bits + name => unicode:chardata() % = 3, optional + }. + +-type route_table_identifier() :: + #{id => non_neg_integer() % = 1, optional, 32 bits + }. + +-type list_route_tables_request() :: + #{network_name => unicode:chardata() % = 1, optional + }. + +-type list_route_tables_response() :: + #{route_tables => [route_table()] % = 1, repeated + }. + +-type create_route_table_request() :: + #{route_table => route_table() % = 1, optional + }. + +-type route_identifier() :: + #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits + destination => unicode:chardata() % = 2, optional + }. + +-type route() :: + #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits + destination => unicode:chardata(), % = 2, optional + gateways => [unicode:chardata()] % = 3, repeated + }. + +-type list_routes_request() :: + #{route_table_id => non_neg_integer() % = 1, optional, 32 bits + }. + +-type list_routes_response() :: + #{routes => [route()] % = 1, repeated + }. + +-type put_route_request() :: + #{route => route() % = 1, optional + }. + +-type sync_request() :: + #{ + }. + +-type empty() :: + #{ + }. + +-export_type(['route_table'/0, 'route_table_identifier'/0, 'list_route_tables_request'/0, 'list_route_tables_response'/0, 'create_route_table_request'/0, 'route_identifier'/0, 'route'/0, 'list_routes_request'/0, 'list_routes_response'/0, 'put_route_request'/0, 'sync_request'/0, 'empty'/0]). +-type '$msg_name'() :: route_table | route_table_identifier | list_route_tables_request | list_route_tables_response | create_route_table_request | route_identifier | route | list_routes_request | list_routes_response | put_route_request | sync_request | empty. +-type '$msg'() :: route_table() | route_table_identifier() | list_route_tables_request() | list_route_tables_response() | create_route_table_request() | route_identifier() | route() | list_routes_request() | list_routes_response() | put_route_request() | sync_request() | empty(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + route_table -> encode_msg_route_table(id(Msg, TrUserData), TrUserData); + route_table_identifier -> encode_msg_route_table_identifier(id(Msg, TrUserData), TrUserData); + list_route_tables_request -> encode_msg_list_route_tables_request(id(Msg, TrUserData), TrUserData); + list_route_tables_response -> encode_msg_list_route_tables_response(id(Msg, TrUserData), TrUserData); + create_route_table_request -> encode_msg_create_route_table_request(id(Msg, TrUserData), TrUserData); + route_identifier -> encode_msg_route_identifier(id(Msg, TrUserData), TrUserData); + route -> encode_msg_route(id(Msg, TrUserData), TrUserData); + list_routes_request -> encode_msg_list_routes_request(id(Msg, TrUserData), TrUserData); + list_routes_response -> encode_msg_list_routes_response(id(Msg, TrUserData), TrUserData); + put_route_request -> encode_msg_put_route_request(id(Msg, TrUserData), TrUserData); + sync_request -> encode_msg_sync_request(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_route_table(Msg, TrUserData) -> encode_msg_route_table(Msg, <<>>, TrUserData). + + +encode_msg_route_table(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{network_name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{id := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= 0 -> B1; + true -> e_varint(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{name := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_route_table_identifier(Msg, TrUserData) -> encode_msg_route_table_identifier(Msg, <<>>, TrUserData). + + +encode_msg_route_table_identifier(#{} = M, Bin, TrUserData) -> + case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_route_tables_request(Msg, TrUserData) -> encode_msg_list_route_tables_request(Msg, <<>>, TrUserData). + + +encode_msg_list_route_tables_request(#{} = M, Bin, TrUserData) -> + case M of + #{network_name := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_route_tables_response(Msg, TrUserData) -> encode_msg_list_route_tables_response(Msg, <<>>, TrUserData). + + +encode_msg_list_route_tables_response(#{} = M, Bin, TrUserData) -> + case M of + #{route_tables := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_route_tables_response_route_tables(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_route_table_request(Msg, TrUserData) -> encode_msg_create_route_table_request(Msg, <<>>, TrUserData). + + +encode_msg_create_route_table_request(#{} = M, Bin, TrUserData) -> + case M of + #{route_table := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_route_table_request_route_table(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_route_identifier(Msg, TrUserData) -> encode_msg_route_identifier(Msg, <<>>, TrUserData). + + +encode_msg_route_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{destination := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_route(Msg, TrUserData) -> encode_msg_route(Msg, <<>>, TrUserData). + + +encode_msg_route(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{destination := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{gateways := F3} -> + TrF3 = id(F3, TrUserData), + if TrF3 == [] -> B2; + true -> e_field_route_gateways(TrF3, B2, TrUserData) + end; + _ -> B2 + end. + +encode_msg_list_routes_request(Msg, TrUserData) -> encode_msg_list_routes_request(Msg, <<>>, TrUserData). + + +encode_msg_list_routes_request(#{} = M, Bin, TrUserData) -> + case M of + #{route_table_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= 0 -> Bin; + true -> e_varint(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_routes_response(Msg, TrUserData) -> encode_msg_list_routes_response(Msg, <<>>, TrUserData). + + +encode_msg_list_routes_response(#{} = M, Bin, TrUserData) -> + case M of + #{routes := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_routes_response_routes(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_put_route_request(Msg, TrUserData) -> encode_msg_put_route_request(Msg, <<>>, TrUserData). + + +encode_msg_put_route_request(#{} = M, Bin, TrUserData) -> + case M of + #{route := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_put_route_request_route(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_sync_request(_Msg, _TrUserData) -> <<>>. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +e_mfield_list_route_tables_response_route_tables(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_route_tables_response_route_tables([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_route_tables_response_route_tables(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_route_tables_response_route_tables(Rest, Bin3, TrUserData); +e_field_list_route_tables_response_route_tables([], Bin, _TrUserData) -> Bin. + +e_mfield_create_route_table_request_route_table(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_route_gateways([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), + e_field_route_gateways(Rest, Bin3, TrUserData); +e_field_route_gateways([], Bin, _TrUserData) -> Bin. + +e_mfield_list_routes_response_routes(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_routes_response_routes([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_routes_response_routes(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_routes_response_routes(Rest, Bin3, TrUserData); +e_field_list_routes_response_routes([], Bin, _TrUserData) -> Bin. + +e_mfield_put_route_request_route(Msg, Bin, TrUserData) -> + SubBin = encode_msg_route(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(route_table, Bin, TrUserData) -> id(decode_msg_route_table(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route_table_identifier, Bin, TrUserData) -> id(decode_msg_route_table_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_route_tables_request, Bin, TrUserData) -> id(decode_msg_list_route_tables_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_route_tables_response, Bin, TrUserData) -> id(decode_msg_list_route_tables_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_route_table_request, Bin, TrUserData) -> id(decode_msg_create_route_table_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route_identifier, Bin, TrUserData) -> id(decode_msg_route_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(route, Bin, TrUserData) -> id(decode_msg_route(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_routes_request, Bin, TrUserData) -> id(decode_msg_list_routes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_routes_response, Bin, TrUserData) -> id(decode_msg_list_routes_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(put_route_request, Bin, TrUserData) -> id(decode_msg_put_route_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(sync_request, Bin, TrUserData) -> id(decode_msg_sync_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). + + + +decode_msg_route_table(Bin, TrUserData) -> dfp_read_field_def_route_table(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_route_table(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}; +dfp_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_route_table_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 16 -> d_field_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_route_table_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}. + +d_field_route_table_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_table(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_route_table_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_table_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_route_table(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_route_table(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_table(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_route_table(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_table(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_route_table(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_route_table(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_route_table_identifier(Bin, TrUserData) -> dfp_read_field_def_route_table_identifier(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). + +dfp_read_field_def_route_table_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_route_table_identifier_id(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}; +dfp_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_table_identifier_id(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}. + +d_field_route_table_identifier_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_route_table_identifier_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_route_table_identifier_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_table_identifier(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_route_table_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_route_table_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_table_identifier(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_route_table_identifier(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_table_identifier(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_route_table_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_route_table_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_route_tables_request(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_route_tables_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_request_network_name(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}; +dfp_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_route_tables_request_network_name(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}. + +d_field_list_route_tables_request_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_request_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_route_tables_request_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_route_tables_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_route_tables_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_route_tables_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_route_tables_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_route_tables_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_route_tables_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_route_tables_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_route_tables_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_route_tables_response(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_route_tables_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_response_route_tables(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{route_tables => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_route_tables_response_route_tables(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{route_tables => lists_reverse(R1, TrUserData)} + end. + +d_field_list_route_tables_response_route_tables(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_response_route_tables(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_route_tables_response_route_tables(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_route_tables_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_route_tables_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_route_tables_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_route_tables_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_route_tables_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_route_tables_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_route_tables_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_route_tables_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_route_table_request(Bin, TrUserData) -> dfp_read_field_def_create_route_table_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_create_route_table_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_route_table_request_route_table(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route_table => F@_1} + end; +dfp_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_route_table_request_route_table(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route_table => F@_1} + end. + +d_field_create_route_table_request_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_route_table_request_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_create_route_table_request_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_route_table_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_route_table(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_create_route_table_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_create_route_table_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_route_table_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_create_route_table_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_route_table_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_create_route_table_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_create_route_table_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_route_identifier(Bin, TrUserData) -> dfp_read_field_def_route_identifier(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_route_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_route_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_destination(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}; +dfp_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_identifier_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_route_identifier_destination(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}. + +d_field_route_identifier_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_route_identifier_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_route_identifier_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_route_identifier_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_route_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_route_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_route_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_route_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_route_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_route(Bin, TrUserData) -> dfp_read_field_def_route(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id([], TrUserData), TrUserData). + +dfp_read_field_def_route(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_destination(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_gateways(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}; +dfp_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_route(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_route_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_route_destination(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_route_gateways(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}. + +d_field_route_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_route(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_route_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_route_gateways(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_gateways(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_route_gateways(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_route(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_route(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_route(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_route(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_route(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_route(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_route(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_route(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_routes_request(Bin, TrUserData) -> dfp_read_field_def_list_routes_request(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). + +dfp_read_field_def_list_routes_request(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_request_route_table_id(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}; +dfp_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_list_routes_request_route_table_id(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}. + +d_field_list_routes_request_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_request_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_routes_request_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, + dfp_read_field_def_list_routes_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_routes_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_routes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_routes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_routes_response(Bin, TrUserData) -> dfp_read_field_def_list_routes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_routes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_response_routes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{routes => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_routes_response_routes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{routes => lists_reverse(R1, TrUserData)} + end. + +d_field_list_routes_response_routes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_response_routes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_routes_response_routes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_routes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_routes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_routes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_routes_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_routes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_routes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_routes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_routes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_put_route_request(Bin, TrUserData) -> dfp_read_field_def_put_route_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_put_route_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_route_request_route(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route => F@_1} + end; +dfp_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_put_route_request_route(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> + S1 = #{}, + if F@_1 == '$undef' -> S1; + true -> S1#{route => F@_1} + end. + +d_field_put_route_request_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_route_request_route(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_put_route_request_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_put_route_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_route(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_put_route_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_put_route_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_put_route_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_put_route_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_put_route_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_put_route_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_put_route_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_sync_request(Bin, TrUserData) -> dfp_read_field_def_sync_request(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_sync_request(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_sync_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_request(Rest, Z1, Z2, F, TrUserData); +skip_varint_sync_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_sync_request(Rest2, 0, 0, F, TrUserData). + +skip_group_sync_request(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_sync_request(Rest, 0, Z2, FNum, TrUserData). + +skip_32_sync_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +skip_64_sync_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + route_table -> merge_msg_route_table(Prev, New, TrUserData); + route_table_identifier -> merge_msg_route_table_identifier(Prev, New, TrUserData); + list_route_tables_request -> merge_msg_list_route_tables_request(Prev, New, TrUserData); + list_route_tables_response -> merge_msg_list_route_tables_response(Prev, New, TrUserData); + create_route_table_request -> merge_msg_create_route_table_request(Prev, New, TrUserData); + route_identifier -> merge_msg_route_identifier(Prev, New, TrUserData); + route -> merge_msg_route(Prev, New, TrUserData); + list_routes_request -> merge_msg_list_routes_request(Prev, New, TrUserData); + list_routes_response -> merge_msg_list_routes_response(Prev, New, TrUserData); + put_route_request -> merge_msg_put_route_request(Prev, New, TrUserData); + sync_request -> merge_msg_sync_request(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_route_table/3}). +merge_msg_route_table(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; + {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S2#{id => NFid}; + {#{id := PFid}, _} -> S2#{id => PFid}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{name := NFname}} -> S3#{name => NFname}; + {#{name := PFname}, _} -> S3#{name => PFname}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_route_table_identifier/3}). +merge_msg_route_table_identifier(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_route_tables_request/3}). +merge_msg_list_route_tables_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; + {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_route_tables_response/3}). +merge_msg_list_route_tables_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route_tables := PFroute_tables}, #{route_tables := NFroute_tables}} -> S1#{route_tables => 'erlang_++'(PFroute_tables, NFroute_tables, TrUserData)}; + {_, #{route_tables := NFroute_tables}} -> S1#{route_tables => NFroute_tables}; + {#{route_tables := PFroute_tables}, _} -> S1#{route_tables => PFroute_tables}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_route_table_request/3}). +merge_msg_create_route_table_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route_table := PFroute_table}, #{route_table := NFroute_table}} -> S1#{route_table => merge_msg_route_table(PFroute_table, NFroute_table, TrUserData)}; + {_, #{route_table := NFroute_table}} -> S1#{route_table => NFroute_table}; + {#{route_table := PFroute_table}, _} -> S1#{route_table => PFroute_table}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_route_identifier/3}). +merge_msg_route_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; + {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_route/3}). +merge_msg_route(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; + {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; + _ -> S2 + end, + case {PMsg, NMsg} of + {#{gateways := PFgateways}, #{gateways := NFgateways}} -> S3#{gateways => 'erlang_++'(PFgateways, NFgateways, TrUserData)}; + {_, #{gateways := NFgateways}} -> S3#{gateways => NFgateways}; + {#{gateways := PFgateways}, _} -> S3#{gateways => PFgateways}; + {_, _} -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_routes_request/3}). +merge_msg_list_routes_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; + {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_routes_response/3}). +merge_msg_list_routes_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{routes := PFroutes}, #{routes := NFroutes}} -> S1#{routes => 'erlang_++'(PFroutes, NFroutes, TrUserData)}; + {_, #{routes := NFroutes}} -> S1#{routes => NFroutes}; + {#{routes := PFroutes}, _} -> S1#{routes => PFroutes}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_put_route_request/3}). +merge_msg_put_route_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{route := PFroute}, #{route := NFroute}} -> S1#{route => merge_msg_route(PFroute, NFroute, TrUserData)}; + {_, #{route := NFroute}} -> S1#{route => NFroute}; + {#{route := PFroute}, _} -> S1#{route => PFroute}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_sync_request/3}). +merge_msg_sync_request(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + route_table -> v_msg_route_table(Msg, [MsgName], TrUserData); + route_table_identifier -> v_msg_route_table_identifier(Msg, [MsgName], TrUserData); + list_route_tables_request -> v_msg_list_route_tables_request(Msg, [MsgName], TrUserData); + list_route_tables_response -> v_msg_list_route_tables_response(Msg, [MsgName], TrUserData); + create_route_table_request -> v_msg_create_route_table_request(Msg, [MsgName], TrUserData); + route_identifier -> v_msg_route_identifier(Msg, [MsgName], TrUserData); + route -> v_msg_route(Msg, [MsgName], TrUserData); + list_routes_request -> v_msg_list_routes_request(Msg, [MsgName], TrUserData); + list_routes_response -> v_msg_list_routes_response(Msg, [MsgName], TrUserData); + put_route_request -> v_msg_put_route_request(Msg, [MsgName], TrUserData); + sync_request -> v_msg_sync_request(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_route_table/3}). +-dialyzer({nowarn_function,v_msg_route_table/3}). +v_msg_route_table(#{} = M, Path, TrUserData) -> + case M of + #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); + _ -> ok + end, + case M of + #{id := F2} -> v_type_uint32(F2, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network_name) -> ok; + (id) -> ok; + (name) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_table(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table}, M, Path); +v_msg_route_table(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table}, X, Path). + +-compile({nowarn_unused_function,v_msg_route_table_identifier/3}). +-dialyzer({nowarn_function,v_msg_route_table_identifier/3}). +v_msg_route_table_identifier(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_uint32(F1, [id | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_table_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table_identifier}, M, Path); +v_msg_route_table_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_route_tables_request/3}). +-dialyzer({nowarn_function,v_msg_list_route_tables_request/3}). +v_msg_list_route_tables_request(#{} = M, Path, TrUserData) -> + case M of + #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (network_name) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_route_tables_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_request}, M, Path); +v_msg_list_route_tables_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_route_tables_response/3}). +-dialyzer({nowarn_function,v_msg_list_route_tables_response/3}). +v_msg_list_route_tables_response(#{} = M, Path, TrUserData) -> + case M of + #{route_tables := F1} -> + if is_list(F1) -> + _ = [v_msg_route_table(Elem, [route_tables | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, route_table}}, F1, [route_tables | Path]) + end; + _ -> ok + end, + lists:foreach(fun (route_tables) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_route_tables_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_response}, M, Path); +v_msg_list_route_tables_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_route_table_request/3}). +-dialyzer({nowarn_function,v_msg_create_route_table_request/3}). +v_msg_create_route_table_request(#{} = M, Path, TrUserData) -> + case M of + #{route_table := F1} -> v_msg_route_table(F1, [route_table | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_route_table_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_route_table_request}, M, Path); +v_msg_create_route_table_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_route_table_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_route_identifier/3}). +-dialyzer({nowarn_function,v_msg_route_identifier/3}). +v_msg_route_identifier(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + case M of + #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (destination) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_identifier}, M, Path); +v_msg_route_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_route/3}). +-dialyzer({nowarn_function,v_msg_route/3}). +v_msg_route(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + case M of + #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); + _ -> ok + end, + case M of + #{gateways := F3} -> + if is_list(F3) -> + _ = [v_type_string(Elem, [gateways | Path], TrUserData) || Elem <- F3], + ok; + true -> mk_type_error({invalid_list_of, string}, F3, [gateways | Path]) + end; + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (destination) -> ok; + (gateways) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_route(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route}, M, Path); +v_msg_route(X, Path, _TrUserData) -> mk_type_error({expected_msg, route}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_routes_request/3}). +-dialyzer({nowarn_function,v_msg_list_routes_request/3}). +v_msg_list_routes_request(#{} = M, Path, TrUserData) -> + case M of + #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route_table_id) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_request}, M, Path); +v_msg_list_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_routes_response/3}). +-dialyzer({nowarn_function,v_msg_list_routes_response/3}). +v_msg_list_routes_response(#{} = M, Path, TrUserData) -> + case M of + #{routes := F1} -> + if is_list(F1) -> + _ = [v_msg_route(Elem, [routes | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, route}}, F1, [routes | Path]) + end; + _ -> ok + end, + lists:foreach(fun (routes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_routes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_response}, M, Path); +v_msg_list_routes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_put_route_request/3}). +-dialyzer({nowarn_function,v_msg_put_route_request/3}). +v_msg_put_route_request(#{} = M, Path, TrUserData) -> + case M of + #{route := F1} -> v_msg_route(F1, [route | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (route) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_put_route_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_route_request}, M, Path); +v_msg_put_route_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_route_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_sync_request/3}). +-dialyzer({nowarn_function,v_msg_sync_request/3}). +v_msg_sync_request(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_sync_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_request}, M, Path); +v_msg_sync_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_type_uint32/3}). +-dialyzer({nowarn_function,v_type_uint32/3}). +v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; +v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); +v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, route_table}, + [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, route_table_identifier}, [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_route_tables_request}, [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_route_tables_response}, [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]}, + {{msg, create_route_table_request}, [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]}, + {{msg, route_identifier}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, route}, + [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, + #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]}, + {{msg, list_routes_request}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, + {{msg, list_routes_response}, [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]}, + {{msg, put_route_request}, [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]}, + {{msg, sync_request}, []}, + {{msg, empty}, []}]. + + +get_msg_names() -> [route_table, route_table_identifier, list_route_tables_request, list_route_tables_response, create_route_table_request, route_identifier, route, list_routes_request, list_routes_response, put_route_request, sync_request, empty]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> + [route_table, route_table_identifier, list_route_tables_request, list_route_tables_response, create_route_table_request, route_identifier, route, list_routes_request, list_routes_response, put_route_request, sync_request, empty]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(route_table) -> + [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, + #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(route_table_identifier) -> [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_route_tables_request) -> [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_route_tables_response) -> [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]; +find_msg_def(create_route_table_request) -> [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]; +find_msg_def(route_identifier) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(route) -> + [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, + #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]; +find_msg_def(list_routes_request) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; +find_msg_def(list_routes_response) -> [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]; +find_msg_def(put_route_request) -> [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]; +find_msg_def(sync_request) -> []; +find_msg_def(empty) -> []; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['RouteService']. + + +get_service_def('RouteService') -> + {{service, 'RouteService'}, + [#{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('RouteService') -> ['GetRouteTable', 'ListRouteTables', 'CreateRouteTable', 'DeleteRouteTable', 'GetRoute', 'ListRoutes', 'PutRoute', 'DeleteRoute', 'Sync']; +get_rpc_names(_) -> error. + + +find_rpc_def('RouteService', RpcName) -> find_rpc_def_RouteService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_RouteService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService('Sync') -> #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_RouteService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"RouteService">>) -> 'RouteService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('RouteService') -> <<"RouteService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRouteTable">>) -> {'RouteService', 'GetRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRouteTables">>) -> {'RouteService', 'ListRouteTables'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"CreateRouteTable">>) -> {'RouteService', 'CreateRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRouteTable">>) -> {'RouteService', 'DeleteRouteTable'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRoute">>) -> {'RouteService', 'GetRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRoutes">>) -> {'RouteService', 'ListRoutes'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"PutRoute">>) -> {'RouteService', 'PutRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRoute">>) -> {'RouteService', 'DeleteRoute'}; +fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"Sync">>) -> {'RouteService', 'Sync'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('RouteService', 'GetRouteTable') -> {<<"RouteService">>, <<"GetRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'ListRouteTables') -> {<<"RouteService">>, <<"ListRouteTables">>}; +service_and_rpc_name_to_fqbins('RouteService', 'CreateRouteTable') -> {<<"RouteService">>, <<"CreateRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'DeleteRouteTable') -> {<<"RouteService">>, <<"DeleteRouteTable">>}; +service_and_rpc_name_to_fqbins('RouteService', 'GetRoute') -> {<<"RouteService">>, <<"GetRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'ListRoutes') -> {<<"RouteService">>, <<"ListRoutes">>}; +service_and_rpc_name_to_fqbins('RouteService', 'PutRoute') -> {<<"RouteService">>, <<"PutRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'DeleteRoute') -> {<<"RouteService">>, <<"DeleteRoute">>}; +service_and_rpc_name_to_fqbins('RouteService', 'Sync') -> {<<"RouteService">>, <<"Sync">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"RouteTable">>) -> route_table; +fqbin_to_msg_name(<<"RouteTableIdentifier">>) -> route_table_identifier; +fqbin_to_msg_name(<<"ListRouteTablesRequest">>) -> list_route_tables_request; +fqbin_to_msg_name(<<"ListRouteTablesResponse">>) -> list_route_tables_response; +fqbin_to_msg_name(<<"CreateRouteTableRequest">>) -> create_route_table_request; +fqbin_to_msg_name(<<"RouteIdentifier">>) -> route_identifier; +fqbin_to_msg_name(<<"Route">>) -> route; +fqbin_to_msg_name(<<"ListRoutesRequest">>) -> list_routes_request; +fqbin_to_msg_name(<<"ListRoutesResponse">>) -> list_routes_response; +fqbin_to_msg_name(<<"PutRouteRequest">>) -> put_route_request; +fqbin_to_msg_name(<<"SyncRequest">>) -> sync_request; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(route_table) -> <<"RouteTable">>; +msg_name_to_fqbin(route_table_identifier) -> <<"RouteTableIdentifier">>; +msg_name_to_fqbin(list_route_tables_request) -> <<"ListRouteTablesRequest">>; +msg_name_to_fqbin(list_route_tables_response) -> <<"ListRouteTablesResponse">>; +msg_name_to_fqbin(create_route_table_request) -> <<"CreateRouteTableRequest">>; +msg_name_to_fqbin(route_identifier) -> <<"RouteIdentifier">>; +msg_name_to_fqbin(route) -> <<"Route">>; +msg_name_to_fqbin(list_routes_request) -> <<"ListRoutesRequest">>; +msg_name_to_fqbin(list_routes_response) -> <<"ListRoutesResponse">>; +msg_name_to_fqbin(put_route_request) -> <<"PutRouteRequest">>; +msg_name_to_fqbin(sync_request) -> <<"SyncRequest">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "route.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["route.proto", "empty.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["route", "empty"]. + + +get_msg_containment("route") -> + [create_route_table_request, list_route_tables_request, list_route_tables_response, list_routes_request, list_routes_response, put_route_request, route, route_identifier, route_table, route_table_identifier, sync_request]; +get_msg_containment("empty") -> [empty]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("route") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("route") -> ['RouteService']; +get_service_containment("empty") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("route") -> + [{'RouteService', 'GetRouteTable'}, + {'RouteService', 'ListRouteTables'}, + {'RouteService', 'CreateRouteTable'}, + {'RouteService', 'DeleteRouteTable'}, + {'RouteService', 'GetRoute'}, + {'RouteService', 'ListRoutes'}, + {'RouteService', 'PutRoute'}, + {'RouteService', 'DeleteRoute'}, + {'RouteService', 'Sync'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("route") -> []; +get_enum_containment("empty") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"RouteTableIdentifier">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"RouteIdentifier">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"SyncRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"PutRouteRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRoutesRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"CreateRouteTableRequest">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"RouteTable">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"Route">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRoutesResponse">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesResponse">>) -> "route"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"RouteService">>) -> "route"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/route_service_bhvr.erl b/virtuerl/src/pb/route_service_bhvr.erl new file mode 100644 index 0000000..35673a4 --- /dev/null +++ b/virtuerl/src/pb/route_service_bhvr.erl @@ -0,0 +1,45 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service RouteService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(route_service_bhvr). + +%% Unary RPC +-callback get_route_table(ctx:t(), route_pb:route_table_identifier()) -> + {ok, route_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_route_tables(ctx:t(), route_pb:list_route_tables_request()) -> + {ok, route_pb:list_route_tables_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_route_table(ctx:t(), route_pb:create_route_table_request()) -> + {ok, route_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_route_table(ctx:t(), route_pb:route_table_identifier()) -> + {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_route(ctx:t(), route_pb:route_identifier()) -> + {ok, route_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_routes(ctx:t(), route_pb:list_routes_request()) -> + {ok, route_pb:list_routes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback put_route(ctx:t(), route_pb:put_route_request()) -> + {ok, route_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_route(ctx:t(), route_pb:route_identifier()) -> + {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback sync(ctx:t(), route_pb:sync_request()) -> + {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/route_service_client.erl b/virtuerl/src/pb/route_service_client.erl new file mode 100644 index 0000000..c36b8bf --- /dev/null +++ b/virtuerl/src/pb/route_service_client.erl @@ -0,0 +1,187 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service RouteService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(route_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'RouteService'). +-define(PROTO_MODULE, 'route_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_route_table(route_pb:route_table_identifier()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Input) -> + get_route_table(ctx:new(), Input, #{}). + +-spec get_route_table(ctx:t() | route_pb:route_table_identifier(), route_pb:route_table_identifier() | grpcbox_client:options()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + get_route_table(Ctx, Input, #{}); +get_route_table(Input, Options) -> + get_route_table(ctx:new(), Input, Options). + +-spec get_route_table(ctx:t(), route_pb:route_table_identifier(), grpcbox_client:options()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/GetRouteTable">>, Input, ?DEF(route_table_identifier, route_table, <<"RouteTableIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_route_tables(route_pb:list_route_tables_request()) -> + {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Input) -> + list_route_tables(ctx:new(), Input, #{}). + +-spec list_route_tables(ctx:t() | route_pb:list_route_tables_request(), route_pb:list_route_tables_request() | grpcbox_client:options()) -> + {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Ctx, Input) when ?is_ctx(Ctx) -> + list_route_tables(Ctx, Input, #{}); +list_route_tables(Input, Options) -> + list_route_tables(ctx:new(), Input, Options). + +-spec list_route_tables(ctx:t(), route_pb:list_route_tables_request(), grpcbox_client:options()) -> + {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_route_tables(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/ListRouteTables">>, Input, ?DEF(list_route_tables_request, list_route_tables_response, <<"ListRouteTablesRequest">>), Options). + +%% @doc Unary RPC +-spec create_route_table(route_pb:create_route_table_request()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Input) -> + create_route_table(ctx:new(), Input, #{}). + +-spec create_route_table(ctx:t() | route_pb:create_route_table_request(), route_pb:create_route_table_request() | grpcbox_client:options()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + create_route_table(Ctx, Input, #{}); +create_route_table(Input, Options) -> + create_route_table(ctx:new(), Input, Options). + +-spec create_route_table(ctx:t(), route_pb:create_route_table_request(), grpcbox_client:options()) -> + {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/CreateRouteTable">>, Input, ?DEF(create_route_table_request, route_table, <<"CreateRouteTableRequest">>), Options). + +%% @doc Unary RPC +-spec delete_route_table(route_pb:route_table_identifier()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Input) -> + delete_route_table(ctx:new(), Input, #{}). + +-spec delete_route_table(ctx:t() | route_pb:route_table_identifier(), route_pb:route_table_identifier() | grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Ctx, Input) when ?is_ctx(Ctx) -> + delete_route_table(Ctx, Input, #{}); +delete_route_table(Input, Options) -> + delete_route_table(ctx:new(), Input, Options). + +-spec delete_route_table(ctx:t(), route_pb:route_table_identifier(), grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route_table(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/DeleteRouteTable">>, Input, ?DEF(route_table_identifier, empty, <<"RouteTableIdentifier">>), Options). + +%% @doc Unary RPC +-spec get_route(route_pb:route_identifier()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Input) -> + get_route(ctx:new(), Input, #{}). + +-spec get_route(ctx:t() | route_pb:route_identifier(), route_pb:route_identifier() | grpcbox_client:options()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Ctx, Input) when ?is_ctx(Ctx) -> + get_route(Ctx, Input, #{}); +get_route(Input, Options) -> + get_route(ctx:new(), Input, Options). + +-spec get_route(ctx:t(), route_pb:route_identifier(), grpcbox_client:options()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/GetRoute">>, Input, ?DEF(route_identifier, route, <<"RouteIdentifier">>), Options). + +%% @doc Unary RPC +-spec list_routes(route_pb:list_routes_request()) -> + {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Input) -> + list_routes(ctx:new(), Input, #{}). + +-spec list_routes(ctx:t() | route_pb:list_routes_request(), route_pb:list_routes_request() | grpcbox_client:options()) -> + {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Ctx, Input) when ?is_ctx(Ctx) -> + list_routes(Ctx, Input, #{}); +list_routes(Input, Options) -> + list_routes(ctx:new(), Input, Options). + +-spec list_routes(ctx:t(), route_pb:list_routes_request(), grpcbox_client:options()) -> + {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_routes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/ListRoutes">>, Input, ?DEF(list_routes_request, list_routes_response, <<"ListRoutesRequest">>), Options). + +%% @doc Unary RPC +-spec put_route(route_pb:put_route_request()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Input) -> + put_route(ctx:new(), Input, #{}). + +-spec put_route(ctx:t() | route_pb:put_route_request(), route_pb:put_route_request() | grpcbox_client:options()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Ctx, Input) when ?is_ctx(Ctx) -> + put_route(Ctx, Input, #{}); +put_route(Input, Options) -> + put_route(ctx:new(), Input, Options). + +-spec put_route(ctx:t(), route_pb:put_route_request(), grpcbox_client:options()) -> + {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +put_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/PutRoute">>, Input, ?DEF(put_route_request, route, <<"PutRouteRequest">>), Options). + +%% @doc Unary RPC +-spec delete_route(route_pb:route_identifier()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Input) -> + delete_route(ctx:new(), Input, #{}). + +-spec delete_route(ctx:t() | route_pb:route_identifier(), route_pb:route_identifier() | grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Ctx, Input) when ?is_ctx(Ctx) -> + delete_route(Ctx, Input, #{}); +delete_route(Input, Options) -> + delete_route(ctx:new(), Input, Options). + +-spec delete_route(ctx:t(), route_pb:route_identifier(), grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_route(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/DeleteRoute">>, Input, ?DEF(route_identifier, empty, <<"RouteIdentifier">>), Options). + +%% @doc Unary RPC +-spec sync(route_pb:sync_request()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync(Input) -> + sync(ctx:new(), Input, #{}). + +-spec sync(ctx:t() | route_pb:sync_request(), route_pb:sync_request() | grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync(Ctx, Input) when ?is_ctx(Ctx) -> + sync(Ctx, Input, #{}); +sync(Input, Options) -> + sync(ctx:new(), Input, Options). + +-spec sync(ctx:t(), route_pb:sync_request(), grpcbox_client:options()) -> + {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +sync(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/RouteService/Sync">>, Input, ?DEF(sync_request, empty, <<"SyncRequest">>), Options). + diff --git a/virtuerl/src/pb/volume_pb.erl b/virtuerl/src/pb/volume_pb.erl new file mode 100644 index 0000000..106a556 --- /dev/null +++ b/virtuerl/src/pb/volume_pb.erl @@ -0,0 +1,2159 @@ +%% -*- coding: utf-8 -*- +%% @private +%% Automatically generated, do not edit +%% Generated by gpb_compile version 4.19.8 +%% Version source: file +-module(volume_pb). + +-export([encode_msg/2, encode_msg/3]). +-export([decode_msg/2, decode_msg/3]). +-export([merge_msgs/3, merge_msgs/4]). +-export([verify_msg/2, verify_msg/3]). +-export([get_msg_defs/0]). +-export([get_msg_names/0]). +-export([get_group_names/0]). +-export([get_msg_or_group_names/0]). +-export([get_enum_names/0]). +-export([find_msg_def/1, fetch_msg_def/1]). +-export([find_enum_def/1, fetch_enum_def/1]). +-export([enum_symbol_by_value/2, enum_value_by_symbol/2]). +-export([get_service_names/0]). +-export([get_service_def/1]). +-export([get_rpc_names/1]). +-export([find_rpc_def/2, fetch_rpc_def/2]). +-export([fqbin_to_service_name/1]). +-export([service_name_to_fqbin/1]). +-export([fqbins_to_service_and_rpc_name/2]). +-export([service_and_rpc_name_to_fqbins/2]). +-export([fqbin_to_msg_name/1]). +-export([msg_name_to_fqbin/1]). +-export([fqbin_to_enum_name/1]). +-export([enum_name_to_fqbin/1]). +-export([get_package_name/0]). +-export([uses_packages/0]). +-export([source_basename/0]). +-export([get_all_source_basenames/0]). +-export([get_all_proto_names/0]). +-export([get_msg_containment/1]). +-export([get_pkg_containment/1]). +-export([get_service_containment/1]). +-export([get_rpc_containment/1]). +-export([get_enum_containment/1]). +-export([get_proto_by_msg_name_as_fqbin/1]). +-export([get_proto_by_service_name_as_fqbin/1]). +-export([get_proto_by_enum_name_as_fqbin/1]). +-export([get_protos_by_pkg_name_as_fqbin/1]). +-export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). + + +%% enumerated types + +-export_type([]). + +%% message types +-type get_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume() :: + #{id => unicode:chardata(), % = 1, optional + name => unicode:chardata(), % = 2, optional + size => non_neg_integer() % = 3, optional, 64 bits + }. + +-type list_volumes_request() :: + #{host => unicode:chardata() % = 1, optional + }. + +-type list_volumes_response() :: + #{volumes => [volume()] % = 1, repeated + }. + +-type create_volume_request() :: + #{volume => volume(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type update_volume_request() :: + #{host => unicode:chardata(), % = 1, optional + volume => volume() % = 2, optional + }. + +-type delete_volume_request() :: + #{uuid => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type volume_attachment_identifier() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + host => unicode:chardata() % = 3, optional + }. + +-type volume_attachment() :: + #{domain_id => unicode:chardata(), % = 1, optional + volume_id => unicode:chardata(), % = 2, optional + disk_address => unicode:chardata() % = 3, optional + }. + +-type list_volume_attachments_request() :: + #{domain_id => unicode:chardata(), % = 1, optional + host => unicode:chardata() % = 2, optional + }. + +-type list_volume_attachments_response() :: + #{attachments => [volume_attachment()] % = 1, repeated + }. + +-type empty() :: + #{ + }. + +-export_type(['get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'empty'/0]). +-type '$msg_name'() :: get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | empty. +-type '$msg'() :: get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | empty(). +-export_type(['$msg_name'/0, '$msg'/0]). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). + +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). +encode_msg(Msg, MsgName, Opts) -> + case proplists:get_bool(verify, Opts) of + true -> verify_msg(Msg, MsgName, Opts); + false -> ok + end, + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); + volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); + list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); + list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); + create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); + update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); + delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); + volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); + volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); + list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); + list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); + empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) + end. + + +encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). + + +encode_msg_volume(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{name := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{size := F3} -> + begin + TrF3 = id(F3, TrUserData), + if TrF3 =:= 0 -> B2; + true -> e_varint(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> + case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end. + +encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> + case M of + #{volumes := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{volume := F1} -> + begin + TrF1 = id(F1, TrUserData), + if TrF1 =:= undefined -> Bin; + true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{host := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{volume := F2} -> + begin + TrF2 = id(F2, TrUserData), + if TrF2 =:= undefined -> B1; + true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). + + +encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{uuid := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{host := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). + + +encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + B2 = case M of + #{volume_id := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end, + case M of + #{disk_address := F3} -> + begin + TrF3 = id(F3, TrUserData), + case is_empty_string(TrF3) of + true -> B2; + false -> e_type_string(TrF3, <>, TrUserData) + end + end; + _ -> B2 + end. + +encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> + B1 = case M of + #{domain_id := F1} -> + begin + TrF1 = id(F1, TrUserData), + case is_empty_string(TrF1) of + true -> Bin; + false -> e_type_string(TrF1, <>, TrUserData) + end + end; + _ -> Bin + end, + case M of + #{host := F2} -> + begin + TrF2 = id(F2, TrUserData), + case is_empty_string(TrF2) of + true -> B1; + false -> e_type_string(TrF2, <>, TrUserData) + end + end; + _ -> B1 + end. + +encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). + + +encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> + case M of + #{attachments := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) + end; + _ -> Bin + end. + +encode_msg_empty(_Msg, _TrUserData) -> <<>>. + +e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); +e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. + +e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> + SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + +e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> + Bin2 = <>, + Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), + e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); +e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. + +-compile({nowarn_unused_function,e_type_sint/3}). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). + +-compile({nowarn_unused_function,e_type_int32/3}). +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int32(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_int64/3}). +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; +e_type_int64(Value, Bin, _TrUserData) -> + <> = <>, + e_varint(N, Bin). + +-compile({nowarn_unused_function,e_type_bool/3}). +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; +e_type_bool(1, Bin, _TrUserData) -> <>; +e_type_bool(0, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_string/3}). +e_type_string(S, Bin, _TrUserData) -> + Utf8 = unicode:characters_to_binary(S), + Bin2 = e_varint(byte_size(Utf8), Bin), + <>. + +-compile({nowarn_unused_function,e_type_bytes/3}). +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> + Bin2 = e_varint(byte_size(Bytes), Bin), + <>; +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> + BytesBin = iolist_to_binary(Bytes), + Bin2 = e_varint(byte_size(BytesBin), Bin), + <>. + +-compile({nowarn_unused_function,e_type_fixed32/3}). +e_type_fixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed32/3}). +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_fixed64/3}). +e_type_fixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_sfixed64/3}). +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. + +-compile({nowarn_unused_function,e_type_float/3}). +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_type_double/3}). +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. + +-compile({nowarn_unused_function,e_varint/3}). +e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). + +-compile({nowarn_unused_function,e_varint/2}). +e_varint(N, Bin) when N =< 127 -> <>; +e_varint(N, Bin) -> + Bin2 = <>, + e_varint(N bsr 7, Bin2). + +is_empty_string("") -> true; +is_empty_string(<<>>) -> true; +is_empty_string(L) when is_list(L) -> not string_has_chars(L); +is_empty_string(B) when is_binary(B) -> false. + +string_has_chars([C | _]) when is_integer(C) -> true; +string_has_chars([H | T]) -> + case string_has_chars(H) of + true -> true; + false -> string_has_chars(T) + end; +string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; +string_has_chars(C) when is_integer(C) -> true; +string_has_chars(<<>>) -> false; +string_has_chars([]) -> false. + + +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). + +decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> + TrUserData = proplists:get_value(user_data, Opts), + decode_msg_1_catch(Bin, MsgName, TrUserData). + +-ifdef('OTP_RELEASE'). +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-else. +decode_msg_1_catch(Bin, MsgName, TrUserData) -> + try decode_msg_2_doit(MsgName, Bin, TrUserData) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + end. +-endif. + +decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); +decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); +decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); +decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). + + + +decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). + +dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; +dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. + +d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, + dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; +dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. + +d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). + +skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{volumes => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end; +dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_2}, + if F@_1 == '$undef' -> S1; + true -> S1#{volume => F@_1} + end. + +d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, + 0, + 0, + F, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + F@_2, + TrUserData). + +d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end; +dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{host => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{volume => F@_2} + end. + +d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_update_volume_request(RestF, + 0, + 0, + F, + F@_1, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_volume(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; +dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. + +d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; +dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. + +d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; +dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end + end; +dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. + +d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). + +skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; +dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. + +d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). + +dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); +dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end; +dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). + +dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); + 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) + end + end; +dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> + S1 = #{}, + if R1 == '$undef' -> S1; + true -> S1#{attachments => lists_reverse(R1, TrUserData)} + end. + +d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). + +skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); +skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); +skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). + +skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). + +skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). + +decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). + +dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; +dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). + +dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> + Key = X bsl N + Acc, + case Key band 7 of + 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); + 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) + end; +dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. + +skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); +skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); +skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). + +skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). + +skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). + +read_group(Bin, FieldNum) -> + {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), + <> = Bin, + {Group, Rest}. + +%% Like skipping over fields, but record the total length, +%% Each field is <(FieldNum bsl 3) bor FieldType> ++ +%% Record the length because varints may be non-optimally encoded. +%% +%% Groups can be nested, but assume the same FieldNum cannot be nested +%% because group field numbers are shared with the rest of the fields +%% numbers. Thus we can search just for an group-end with the same +%% field number. +%% +%% (The only time the same group field number could occur would +%% be in a nested sub message, but then it would be inside a +%% length-delimited entry, which we skip-read by length.) +read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) + when N < (32-7) -> + read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); +read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, + FieldNum) -> + Key = X bsl N + Acc, + TagLen1 = TagLen + 1, + case {Key bsr 3, Key band 7} of + {FieldNum, 4} -> % 4 = group_end + {NumBytes, TagLen1}; + {_, 0} -> % 0 = varint + read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); + {_, 1} -> % 1 = bits64 + <<_:64, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); + {_, 2} -> % 2 = length_delimited + read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); + {_, 3} -> % 3 = group_start + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 4} -> % 4 = group_end + read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); + {_, 5} -> % 5 = bits32 + <<_:32, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) + end. + +read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); +read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> + read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). + +read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) + when N < (64-7) -> + read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); +read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> + Len = X bsl N + Acc, + NumBytes1 = NumBytes + 1, + <<_:Len/binary, Tl2/binary>> = Tl, + read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). + +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). + +merge_msgs(Prev, New, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); + volume -> merge_msg_volume(Prev, New, TrUserData); + list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); + list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); + create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); + update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); + delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); + volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); + volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); + list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); + list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); + empty -> merge_msg_empty(Prev, New, TrUserData) + end. + +-compile({nowarn_unused_function,merge_msg_get_volume_request/3}). +merge_msg_get_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume/3}). +merge_msg_volume(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{id := NFid}} -> S1#{id => NFid}; + {#{id := PFid}, _} -> S1#{id => PFid}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{name := NFname}} -> S2#{name => NFname}; + {#{name := PFname}, _} -> S2#{name => PFname}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{size := NFsize}} -> S3#{size => NFsize}; + {#{size := PFsize}, _} -> S3#{size => PFsize}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). +merge_msg_list_volumes_request(PMsg, NMsg, _) -> + S1 = #{}, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). +merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; + {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; + {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_create_volume_request/3}). +merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; + {_, _} -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_update_volume_request/3}). +merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S1#{host => NFhost}; + {#{host := PFhost}, _} -> S1#{host => PFhost}; + _ -> S1 + end, + case {PMsg, NMsg} of + {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; + {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; + {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; + {_, _} -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). +merge_msg_delete_volume_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; + {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). +merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S3#{host => NFhost}; + {#{host := PFhost}, _} -> S3#{host => PFhost}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_volume_attachment/3}). +merge_msg_volume_attachment(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + S3 = case {PMsg, NMsg} of + {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; + {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; + _ -> S2 + end, + case {PMsg, NMsg} of + {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; + {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; + _ -> S3 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). +merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> + S1 = #{}, + S2 = case {PMsg, NMsg} of + {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; + {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; + _ -> S1 + end, + case {PMsg, NMsg} of + {_, #{host := NFhost}} -> S2#{host => NFhost}; + {#{host := PFhost}, _} -> S2#{host => PFhost}; + _ -> S2 + end. + +-compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). +merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> + S1 = #{}, + case {PMsg, NMsg} of + {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; + {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; + {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; + {_, _} -> S1 + end. + +-compile({nowarn_unused_function,merge_msg_empty/3}). +merge_msg_empty(_Prev, New, _TrUserData) -> New. + + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName, Opts) -> + TrUserData = proplists:get_value(user_data, Opts), + case MsgName of + get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); + volume -> v_msg_volume(Msg, [MsgName], TrUserData); + list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); + list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); + create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); + update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); + delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); + volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); + volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); + list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); + list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); + empty -> v_msg_empty(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) + end. + + +-compile({nowarn_unused_function,v_msg_get_volume_request/3}). +-dialyzer({nowarn_function,v_msg_get_volume_request/3}). +v_msg_get_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); +v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume/3}). +-dialyzer({nowarn_function,v_msg_volume/3}). +v_msg_volume(#{} = M, Path, TrUserData) -> + case M of + #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); + _ -> ok + end, + case M of + #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); + _ -> ok + end, + case M of + #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (id) -> ok; + (name) -> ok; + (size) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); +v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_request/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_request/3}). +v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); +v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volumes_response/3}). +-dialyzer({nowarn_function,v_msg_list_volumes_response/3}). +v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> + case M of + #{volumes := F1} -> + if is_list(F1) -> + _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) + end; + _ -> ok + end, + lists:foreach(fun (volumes) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); +v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_create_volume_request/3}). +-dialyzer({nowarn_function,v_msg_create_volume_request/3}). +v_msg_create_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (volume) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); +v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_update_volume_request/3}). +-dialyzer({nowarn_function,v_msg_update_volume_request/3}). +v_msg_update_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); + _ -> ok + end, + case M of + #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (host) -> ok; + (volume) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); +v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_delete_volume_request/3}). +-dialyzer({nowarn_function,v_msg_delete_volume_request/3}). +v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> + case M of + #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (uuid) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); +v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). +v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); +v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). + +-compile({nowarn_unused_function,v_msg_volume_attachment/3}). +-dialyzer({nowarn_function,v_msg_volume_attachment/3}). +v_msg_volume_attachment(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); + _ -> ok + end, + case M of + #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (volume_id) -> ok; + (disk_address) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); +v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). +v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> + case M of + #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); + _ -> ok + end, + case M of + #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); + _ -> ok + end, + lists:foreach(fun (domain_id) -> ok; + (host) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); +v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). + +-compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). +-dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). +v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> + case M of + #{attachments := F1} -> + if is_list(F1) -> + _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) + end; + _ -> ok + end, + lists:foreach(fun (attachments) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); +v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). + +-compile({nowarn_unused_function,v_msg_empty/3}). +-dialyzer({nowarn_function,v_msg_empty/3}). +v_msg_empty(#{} = M, Path, _) -> + lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), + ok; +v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); +v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). + +-compile({nowarn_unused_function,v_type_uint64/3}). +-dialyzer({nowarn_function,v_type_uint64/3}). +v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; +v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); +v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). + +-compile({nowarn_unused_function,v_type_string/3}). +-dialyzer({nowarn_function,v_type_string/3}). +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> + try unicode:characters_to_binary(S) of + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) + catch + error:badarg -> mk_type_error(bad_unicode_string, S, Path) + end; +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). + +-compile({nowarn_unused_function,mk_type_error/3}). +-spec mk_type_error(_, _, list()) -> no_return(). +mk_type_error(Error, ValueSeen, Path) -> + Path2 = prettify_path(Path), + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). + + +-compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). +prettify_path([]) -> top_level; +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). + + +-compile({nowarn_unused_function,id/2}). +-compile({inline,id/2}). +id(X, _TrUserData) -> X. + +-compile({nowarn_unused_function,v_ok/3}). +-compile({inline,v_ok/3}). +v_ok(_Value, _Path, _TrUserData) -> ok. + +-compile({nowarn_unused_function,m_overwrite/3}). +-compile({inline,m_overwrite/3}). +m_overwrite(_Prev, New, _TrUserData) -> New. + +-compile({nowarn_unused_function,cons/3}). +-compile({inline,cons/3}). +cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. + +-compile({nowarn_unused_function,lists_reverse/2}). +-compile({inline,lists_reverse/2}). +'lists_reverse'(L, _TrUserData) -> lists:reverse(L). +-compile({nowarn_unused_function,'erlang_++'/3}). +-compile({inline,'erlang_++'/3}). +'erlang_++'(A, B, _TrUserData) -> A ++ B. + + +get_msg_defs() -> + [{{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume}, + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, + {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, + {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, + {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment_identifier}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, volume_attachment}, + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, + {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, + {{msg, empty}, []}]. + + +get_msg_names() -> + [get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + empty]. + + +get_group_names() -> []. + + +get_msg_or_group_names() -> + [get_volume_request, + volume, + list_volumes_request, + list_volumes_response, + create_volume_request, + update_volume_request, + delete_volume_request, + volume_attachment_identifier, + volume_attachment, + list_volume_attachments_request, + list_volume_attachments_response, + empty]. + + +get_enum_names() -> []. + + +fetch_msg_def(MsgName) -> + case find_msg_def(MsgName) of + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) + end. + + +-spec fetch_enum_def(_) -> no_return(). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume) -> + [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; +find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; +find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment_identifier) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(volume_attachment) -> + [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, + #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, + #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; +find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; +find_msg_def(empty) -> []; +find_msg_def(_) -> error. + + +find_enum_def(_) -> error. + + +-spec enum_symbol_by_value(_, _) -> no_return(). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). + + +-spec enum_value_by_symbol(_, _) -> no_return(). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). + + + +get_service_names() -> ['VolumeService']. + + +get_service_def('VolumeService') -> + {{service, 'VolumeService'}, + [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, + #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, + #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, + #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, + #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; +get_service_def(_) -> error. + + +get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; +get_rpc_names(_) -> error. + + +find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); +find_rpc_def(_, _) -> error. + + +find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; +find_rpc_def_VolumeService(_) -> error. + + +fetch_rpc_def(ServiceName, RpcName) -> + case find_rpc_def(ServiceName, RpcName) of + Def when is_map(Def) -> Def; + error -> erlang:error({no_such_rpc, ServiceName, RpcName}) + end. + + +%% Convert a a fully qualified (ie with package name) service name +%% as a binary to a service name as an atom. +fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a service name as an atom to a fully qualified +%% (ie with package name) name as a binary. +service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). + + +%% Convert a a fully qualified (ie with package name) service name +%% and an rpc name, both as binaries to a service name and an rpc +%% name, as atoms. +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; +fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +%% Convert a service name and an rpc name, both as atoms, +%% to a fully qualified (ie with package name) service name and +%% an rpc name as binaries. +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; +service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). + + +fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; +fqbin_to_msg_name(<<"Volume">>) -> volume; +fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; +fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; +fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; +fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; +fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; +fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; +fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; +fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; +fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; +fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; +fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). + + +msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; +msg_name_to_fqbin(volume) -> <<"Volume">>; +msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; +msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; +msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; +msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; +msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; +msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; +msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; +msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; +msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; +msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; +msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +-spec fqbin_to_enum_name(_) -> no_return(). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). + + +-spec enum_name_to_fqbin(_) -> no_return(). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_package_name() -> 'google.protobuf'. + + +%% Whether or not the message names +%% are prepended with package name or not. +uses_packages() -> true. + + +source_basename() -> "volume.proto". + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned with extension, +%% see get_all_proto_names/0 for a version that returns +%% the basenames sans extension +get_all_source_basenames() -> ["volume.proto", "empty.proto"]. + + +%% Retrieve all proto file names, also imported ones. +%% The order is top-down. The first element is always the main +%% source file. The files are returned sans .proto extension, +%% to make it easier to use them with the various get_xyz_containment +%% functions. +get_all_proto_names() -> ["volume", "empty"]. + + +get_msg_containment("volume") -> + [create_volume_request, + delete_volume_request, + get_volume_request, + list_volume_attachments_request, + list_volume_attachments_response, + list_volumes_request, + list_volumes_response, + update_volume_request, + volume, + volume_attachment, + volume_attachment_identifier]; +get_msg_containment("empty") -> [empty]; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_pkg_containment("volume") -> undefined; +get_pkg_containment("empty") -> 'google.protobuf'; +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_service_containment("volume") -> ['VolumeService']; +get_service_containment("empty") -> []; +get_service_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_rpc_containment("volume") -> + [{'VolumeService', 'GetVolume'}, + {'VolumeService', 'ListVolumes'}, + {'VolumeService', 'CreateVolume'}, + {'VolumeService', 'UpdateVolume'}, + {'VolumeService', 'DeleteVolume'}, + {'VolumeService', 'ListVolumeAttachments'}, + {'VolumeService', 'GetVolumeAttachment'}, + {'VolumeService', 'AttachVolume'}, + {'VolumeService', 'DetachVolume'}]; +get_rpc_containment("empty") -> []; +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_enum_containment("volume") -> []; +get_enum_containment("empty") -> []; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). + + +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; +get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). + + +get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). + + +-spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). + + +get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). + + + +gpb_version_as_string() -> + "4.19.8". + +gpb_version_as_list() -> + [4,19,8]. + +gpb_version_source() -> + "file". diff --git a/virtuerl/src/pb/volume_service_bhvr.erl b/virtuerl/src/pb/volume_service_bhvr.erl new file mode 100644 index 0000000..4fcf498 --- /dev/null +++ b/virtuerl/src/pb/volume_service_bhvr.erl @@ -0,0 +1,45 @@ +%%%------------------------------------------------------------------- +%% @doc Behaviour to implement for grpc service VolumeService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(volume_service_bhvr). + +%% Unary RPC +-callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). + +%% Unary RPC +-callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). + diff --git a/virtuerl/src/pb/volume_service_client.erl b/virtuerl/src/pb/volume_service_client.erl new file mode 100644 index 0000000..ad18a94 --- /dev/null +++ b/virtuerl/src/pb/volume_service_client.erl @@ -0,0 +1,187 @@ +%%%------------------------------------------------------------------- +%% @doc Client module for grpc service VolumeService. +%% @end +%%%------------------------------------------------------------------- + +%% this module was generated and should not be modified manually + +-module(volume_service_client). + +-compile(export_all). +-compile(nowarn_export_all). + +-include_lib("grpcbox/include/grpcbox.hrl"). + +-define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). + +-define(SERVICE, 'VolumeService'). +-define(PROTO_MODULE, 'controller_pb'). +-define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). +-define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). +-define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, + message_type=MessageType, + marshal_fun=?MARSHAL_FUN(Input), + unmarshal_fun=?UNMARSHAL_FUN(Output)}). + +%% @doc Unary RPC +-spec get_volume(controller_pb:get_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Input) -> + get_volume(ctx:new(), Input, #{}). + +-spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume(Ctx, Input, #{}); +get_volume(Input, Options) -> + get_volume(ctx:new(), Input, Options). + +-spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volumes(controller_pb:list_volumes_request()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Input) -> + list_volumes(ctx:new(), Input, #{}). + +-spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> + list_volumes(Ctx, Input, #{}); +list_volumes(Input, Options) -> + list_volumes(ctx:new(), Input, Options). + +-spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volumes(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). + +%% @doc Unary RPC +-spec create_volume(controller_pb:create_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Input) -> + create_volume(ctx:new(), Input, #{}). + +-spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input) when ?is_ctx(Ctx) -> + create_volume(Ctx, Input, #{}); +create_volume(Input, Options) -> + create_volume(ctx:new(), Input, Options). + +-spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +create_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec update_volume(controller_pb:update_volume_request()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Input) -> + update_volume(ctx:new(), Input, #{}). + +-spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input) when ?is_ctx(Ctx) -> + update_volume(Ctx, Input, #{}); +update_volume(Input, Options) -> + update_volume(ctx:new(), Input, Options). + +-spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +update_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec delete_volume(controller_pb:delete_volume_request()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Input) -> + delete_volume(ctx:new(), Input, #{}). + +-spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> + delete_volume(Ctx, Input, #{}); +delete_volume(Input, Options) -> + delete_volume(ctx:new(), Input, Options). + +-spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +delete_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). + +%% @doc Unary RPC +-spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Input) -> + list_volume_attachments(ctx:new(), Input, #{}). + +-spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> + list_volume_attachments(Ctx, Input, #{}); +list_volume_attachments(Input, Options) -> + list_volume_attachments(ctx:new(), Input, Options). + +-spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> + {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +list_volume_attachments(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). + +%% @doc Unary RPC +-spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Input) -> + get_volume_attachment(ctx:new(), Input, #{}). + +-spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> + get_volume_attachment(Ctx, Input, #{}); +get_volume_attachment(Input, Options) -> + get_volume_attachment(ctx:new(), Input, Options). + +-spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +get_volume_attachment(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec attach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Input) -> + attach_volume(ctx:new(), Input, #{}). + +-spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + attach_volume(Ctx, Input, #{}); +attach_volume(Input, Options) -> + attach_volume(ctx:new(), Input, Options). + +-spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +attach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). + +%% @doc Unary RPC +-spec detach_volume(controller_pb:volume_attachment_identifier()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Input) -> + detach_volume(ctx:new(), Input, #{}). + +-spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> + detach_volume(Ctx, Input, #{}); +detach_volume(Input, Options) -> + detach_volume(ctx:new(), Input, Options). + +-spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> + {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. +detach_volume(Ctx, Input, Options) -> + grpcbox_client:unary(Ctx, <<"/VolumeService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). + diff --git a/virtuerl/src/virtuerl.app.src b/virtuerl/src/virtuerl.app.src new file mode 100644 index 0000000..556bc45 --- /dev/null +++ b/virtuerl/src/virtuerl.app.src @@ -0,0 +1,16 @@ +{application, virtuerl, + [{description, "An OTP application"}, + {vsn, "0.1.0"}, + {registered, []}, + {mod, {virtuerl_app, []}}, + {applications, + [kernel, + stdlib, + cowboy + ]}, + {env,[]}, + {modules, []}, + + {licenses, ["Apache-2.0"]}, + {links, []} + ]}. diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl new file mode 100644 index 0000000..0e795f1 --- /dev/null +++ b/virtuerl/src/virtuerl_api.erl @@ -0,0 +1,163 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_api). + +-behaviour(cowboy_handler). + +-export([start_link/0]). +-export([handle/4]). +%%-export([init/2, content_types_provided/2, to_text/2, allowed_methods/2, content_types_accepted/2, from_json/2]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start_link() -> + mochiweb_http:start_link([ + {name, ?MODULE}, + {loop, fun loop/1}, + {ip, any}, + {port, 8080} + ]). + + +%% 1> {ok,MP} = re:compile("(?A)|(?B)|(?C)"). +%% {ok,{re_pattern,3,0,0, +%% <<69,82,67,80,119,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255, +%% 255,255,...>>}} +%% 2> {namelist, N} = re:inspect(MP,namelist). +%% {namelist,[<<"A">>,<<"B">>,<<"C">>]} +%% 3> {match,L} = re:run("AA",MP,[{capture,all_names,binary}]). +%% {match,[<<"A">>,<<>>,<<>>]} +%% 4> NameMap = lists:zip(N,L). +%% [{<<"A">>,<<"A">>},{<<"B">>,<<>>},{<<"C">>,<<>>}] + +urls() -> + RawURLs = [ + {"^/networks/?$", networks, ['GET']}, + {"^/networks/(?[^/]+)/?$", network, ['GET', 'PUT', 'DELETE']}, + {"^/domains/?$", domains, ['GET', 'POST']}, + {"^/domains/(?[^/]+)/?$", domain, ['GET']} + ], + CompiledUrls = lists:map(fun ({URL, Tag, Methods}) -> + {ok, Pat} = re:compile(URL), + {namelist, Namelist} = re:inspect(Pat, namelist), + {Pat, Namelist, Tag, sets:from_list(Methods)} + end, RawURLs), + CompiledUrls. + +dispatch(Req, []) -> + mochiweb_request:not_found(Req); +dispatch(Req, [{Pat, Namelist, Tag, AllowedMethods}|T]) -> + Path = mochiweb_request:get(path, Req), + case re:run(Path, Pat, [{capture, all_names, list}]) of + {match, Match} -> dispatch_matched(Match, Namelist, Tag, AllowedMethods, Req); + match -> dispatch_matched([], Namelist, Tag, AllowedMethods, Req); + nomatch -> dispatch(Req, T) + end. + +dispatch_matched(Match, Namelist, Tag, AllowedMethods, Req) -> + Method = mochiweb_request:get(method, Req), + case sets:is_element(Method, AllowedMethods) of + false -> mochiweb_request:respond({405, [{"Content-Type", "text/plain"}], "Method Not Allowed"}, Req); + _ -> + PathMap = maps:from_list(lists:zip(lists:map(fun binary_to_atom/1, Namelist), Match)), + io:format("PathMap: ~p~n", [PathMap]), + try handle(Tag, Method, PathMap, Req) + catch + error:function_clause -> mochiweb_request:respond({500, [{"Content-Type", "text/plain"}], "Error"}, Req) +%% ; +%% error:bad_argument -> mochiweb_request:respond({500, [{"Content-Type", "text/plain"}], "Error"}, Req) + end + end. + +loop(Req) -> + dispatch(Req, urls()). + +%% handler +%%init(Req0, State) -> +%% Req = cowboy_req:reply(200, #{<<"content-type">> => <<"text/plain">>}, <<"Hello elloh">>, Req0), +%% {ok, Req, State}. + +%%init(Req, State) -> +%% {cowboy_rest, Req, State}. +%% +%%allowed_methods(Req, State) -> +%% {[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>, <<"POST">>], Req, State}. +%% +%%content_types_accepted(Req, State) -> +%% {[{{<<"application">>, <<"json">>, '*'}, from_json}], +%% Req, State +%% }. +%% +%%from_json(Req, State) -> +%% {ok, RawJSON, Req1} = cowboy_req:read_body(Req), +%% {ok, JSON} = thoas:decode(RawJSON), +%% #{<<"networkID">> := NetworkID} = JSON, +%% Conf = #{network_id => NetworkID}, +%%%% virtuerl_mgt:create_vm(Conf), +%% {true, Req1, State}. +%% +%%content_types_provided(Req, State) -> +%% {[{{<<"text">>, <<"plain">>, '*'}, to_text}], +%% Req, State +%% }. +%% +%%to_text(Req, State) -> +%% {<<"OK">>, Req, State}. + +parse_json(Req) -> + Body = mochiweb_request:recv_body(Req), + {ok, JSON} = thoas:decode(Body), + JSON. + +handle(networks, 'GET', _, Req) -> +%% virtuerl_ipam:ipam_put_net({}), + mochiweb_request:ok({[], "HELLO\n"}, Req); +handle(networks, 'POST', _, Req) -> + JSON = parse_json(Req), + #{<<"network">> := #{<<"cidr">> := CIDR}} = JSON, + {Addr, Prefixlen} = virtuerl_net:parse_cidr(CIDR), + io:format("POST~n"), + io:format("NetworkDef ~p/~p~n", [Addr, Prefixlen]), + virtuerl_ipam:ipam_create_net({Addr, Prefixlen}), + mochiweb_request:ok({[], "HELLO\n"}, Req); +handle(network, 'PUT', #{id := ID}, Req) -> + JSON = parse_json(Req), + #{<<"network">> := #{<<"cidr">> := CIDR}} = JSON, + {Addr, Prefixlen} = virtuerl_net:parse_cidr(CIDR), + io:format("PUT: ~p~n", [ID]), + io:format("NetworkDef ~p/~p~n", [Addr, Prefixlen]), + virtuerl_ipam:ipam_put_net({list_to_binary(ID), Addr, Prefixlen}), + mochiweb_request:ok({[], "HELLO\n"}, Req); +handle(network, 'GET', #{id := ID}, Req) -> + io:format("GET: ~p~n", [ID]), + mochiweb_request:ok({[], "HELLO\n"}, Req); +handle(network, 'DELETE', #{id := ID}, Req) -> + io:format("DELETE: ~p~n", [ID]), + ok = virtuerl_ipam:ipam_delete_net(list_to_binary(ID)), + mochiweb_request:respond({204, [{"Content-Type", "application/json"}], <<"">>}, Req); + +handle(domains, 'POST', _, Req) -> + JSON = parse_json(Req), + #{<<"domain">> := #{<<"network_id">> := NetworkID}} = JSON, + {ok, Resp} = virtuerl_mgt:domain_create(#{network_id => NetworkID}), + #{id := DomainID, tap_name := TapName, ip_addr := IP} = Resp, + RespJSON = thoas:encode(#{id => DomainID, tap_name => TapName, ip_addr => virtuerl_net:format_ip(IP)}), + mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/domains/" ++ binary_to_list(DomainID)}], RespJSON}, Req); +handle(domain, 'GET', #{id := ID}, Req) -> + io:format("DOMAIN GET: ~p~n", [ID]), + DomResp = virtuerl_mgt:domain_get(#{id => list_to_binary(ID)}), + io:format("~p~n", [DomResp]), + case DomResp of + {ok, Dom} -> + mochiweb_request:ok({[], thoas:encode(Dom)}, Req); + notfound -> + mochiweb_request:not_found(Req) + end. diff --git a/virtuerl/src/virtuerl_api_domain_col.erl b/virtuerl/src/virtuerl_api_domain_col.erl new file mode 100644 index 0000000..242a910 --- /dev/null +++ b/virtuerl/src/virtuerl_api_domain_col.erl @@ -0,0 +1,58 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_api_domain_col). + +-behaviour(cowboy_rest). + +%%-export([start_link/0]). +-export([init/2, content_types_provided/2, to_text/2, allowed_methods/2, content_types_accepted/2, from_json/2]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +%%start_link() -> +%% Dispatch = cowboy_router:compile([ +%% {'_', [{"/", virtuerl_api, []}]} +%% ]), +%% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), +%% io:format("RESULT: ~p~n", [Res]), +%% Res. + +%% handler +%%init(Req0, State) -> +%% Req = cowboy_req:reply(200, #{<<"content-type">> => <<"text/plain">>}, <<"Hello elloh">>, Req0), +%% {ok, Req, State}. + +init(Req, State) -> + {cowboy_rest, Req, State}. + +allowed_methods(Req, State) -> + {[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>, <<"POST">>], Req, State}. + +content_types_accepted(Req, State) -> + {[{{<<"application">>, <<"json">>, '*'}, from_json}], + Req, State + }. + +from_json(Req, State) -> + {ok, RawJSON, Req1} = cowboy_req:read_body(Req), + {ok, JSON} = thoas:decode(RawJSON), + #{<<"networkID">> := NetworkID} = JSON, + Conf = #{network_id => NetworkID}, +%% virtuerl_mgt:create_vm(Conf), + {true, Req1, State}. + +content_types_provided(Req, State) -> + {[{{<<"text">>, <<"plain">>, '*'}, to_text}], + Req, State + }. + +to_text(Req, State) -> + {<<"OK">>, Req, State}. diff --git a/virtuerl/src/virtuerl_api_domain_res.erl b/virtuerl/src/virtuerl_api_domain_res.erl new file mode 100644 index 0000000..a405e1f --- /dev/null +++ b/virtuerl/src/virtuerl_api_domain_res.erl @@ -0,0 +1,58 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_api_domain_res). + +-behaviour(cowboy_handler). + +%%-export([start_link/0]). +-export([init/2, content_types_provided/2, to_text/2, allowed_methods/2, content_types_accepted/2, from_json/2]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +%%start_link() -> +%% Dispatch = cowboy_router:compile([ +%% {'_', [{"/", virtuerl_api, []}]} +%% ]), +%% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), +%% io:format("RESULT: ~p~n", [Res]), +%% Res. + +%% handler +%%init(Req0, State) -> +%% Req = cowboy_req:reply(200, #{<<"content-type">> => <<"text/plain">>}, <<"Hello elloh">>, Req0), +%% {ok, Req, State}. + +init(Req, State) -> + {cowboy_rest, Req, State}. + +allowed_methods(Req, State) -> + {[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>, <<"POST">>], Req, State}. + +content_types_accepted(Req, State) -> + {[{{<<"application">>, <<"json">>, '*'}, from_json}], + Req, State + }. + +from_json(Req, State) -> + {ok, RawJSON, Req1} = cowboy_req:read_body(Req), + {ok, JSON} = thoas:decode(RawJSON), + #{<<"networkID">> := NetworkID} = JSON, + Conf = #{network_id => NetworkID}, +%% virtuerl_mgt:create_vm(Conf), + {true, Req1, State}. + +content_types_provided(Req, State) -> + {[{{<<"text">>, <<"plain">>, '*'}, to_text}], + Req, State + }. + +to_text(Req, State) -> + {<<"OK">>, Req, State}. diff --git a/virtuerl/src/virtuerl_app.erl b/virtuerl/src/virtuerl_app.erl new file mode 100644 index 0000000..ed8f686 --- /dev/null +++ b/virtuerl/src/virtuerl_app.erl @@ -0,0 +1,25 @@ +%%%------------------------------------------------------------------- +%% @doc virtuerl public API +%% @end +%%%------------------------------------------------------------------- + +-module(virtuerl_app). + +-behaviour(application). + +-export([start/2, stop/1]). + +%% app start/stop +start(_StartType, _StartArgs) -> +%% Dispatch = cowboy_router:compile([ +%% {'_', [ +%% {"/domains", virtuerl_api, []} +%% ]} +%% ]), +%% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), +%% io:format("RESULT: ~p~n", [Res]), +%% {ok, _} = Res, + virtuerl_sup:start_link(). + +stop(_State) -> + ok. diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl new file mode 100644 index 0000000..06b7cc2 --- /dev/null +++ b/virtuerl/src/virtuerl_ipam.erl @@ -0,0 +1,202 @@ +%%%------------------------------------------------------------------- +%% @doc virtuerl public API +%% @end +%%%------------------------------------------------------------------- + +-module(virtuerl_ipam). + +-behavior(gen_server). + +-export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1]). + +-include_lib("khepri/include/khepri.hrl"). +-include_lib("khepri/src/khepri_error.hrl"). + +req(Msg) -> + %kh ! {self(), Msg}, + %receive + % Res -> + % io:format("Received ~p~n", [Res]) + %end. + %gen_server:call(virtuerl, {ip_put, default, <<"192.168.122.0/24">>, <<"192.168.122.10">>}). + %gen_server:call(virtuerl, {ip_next, default, <<"192.168.122.0/24">>}). + case Msg of + net_put -> + gen_server:call(ipam, {net_put, default, {<<"abcdef">>, <<192:8,168:8,122:8,0:8>>, 24}}); + ip_put -> + gen_server:call(ipam, {ip_put, default, <<"192.168.122.0/24">>, <<"192.168.122.0/28">>, <<"192.168.122.12">>}); + ip_next -> + gen_server:call(ipam, {ip_next, <<"abcdef">>}); + ip_clear -> + gen_server:call(ipam, {ip_clear}), + io:format("something~p~n", ['t']) + end. + + +-record(network, {last_insert, from, to, address, prefixlen}). + +ipam_create_net(NetworkDef) -> + {Address, Prefixlen} = NetworkDef, + ID = binary:encode_hex(<<(rand:uniform(16#FFFFFFFF)-1):32>>), + ipam_put_net({ID, Address, Prefixlen}). + +ipam_put_net(NetworkDef) -> + case gen_server:call(ipam, {net_put, NetworkDef}) of + {ok, Res} -> + Res; + Other -> + Other + end. + +ipam_delete_net(ID) -> + case gen_server:call(ipam, {net_delete, ID}) of + {ok, Res} -> + Res; + Other -> + Other + end. + +ipam_put_ip(NetworkName, IP) -> + gen_server:call(ipam, {ip_put, NetworkName, IP}). + +assign_next(NetworkID, VMID) -> + case gen_server:call(ipam, {ip_next, NetworkID, VMID}) of + {ok, Res} -> + Res; + Other -> + Other + end. + +ipam_next_ip(NetworkName) -> + case gen_server:call(ipam, {ip_next, NetworkName}) of + {ok, Res} -> + Res; + Other -> + Other + end. + +%% entry point by child spec +start_link() -> + io:format("IPAM: start_link~n"), + gen_server:start_link({local, ipam}, ?MODULE, [], []). + +init([]) -> + io:format("starting IPAM service~n"), + {ok, StoreId} = khepri:start(), + init([StoreId]); +init([StoreId]) -> + {ok, StoreId}. + +terminate(_Reason, StoreId) -> + DefaultStoreId = khepri_cluster:get_default_store_id(), + case StoreId of + DefaultStoreId -> + khepri:stop(StoreId); + _ -> + ok + end. + +handle_call({net_put, Network}, _From, StoreId) -> + {ID, Address, PrefixLen} = Network, + {From, To} = get_range({Address, PrefixLen}), + case To - From =< 8 of + false -> + BitLength = bit_size(Address), + ok = khepri:put(StoreId, [network, ID], #network{address = Address, prefixlen = PrefixLen, from= <<(From+8):BitLength>>, to= <>, last_insert= <<(From+8):BitLength>>}), + {reply, ok, StoreId}; + true -> + {reply, {error, network_too_small}, StoreId} + end; +handle_call({net_delete, ID}, _From, StoreId) -> + Ret = khepri:delete(StoreId, [network, ID]), + {reply, Ret, StoreId}; + +handle_call({ip_next, NetworkID}, _From, StoreId) -> handle_call({ip_next, NetworkID, ""}, _From, StoreId); +handle_call({ip_next, NetworkID, DomainID}, _From, StoreId) -> + R = khepri:transaction(StoreId, fun() -> + case khepri_tx:get([network, NetworkID]) of + {ok, Network} -> + #network{address = Address, prefixlen = PrefixLen, last_insert= LastInsertBin, from= FromBin, to= ToBin} = Network, + BitLength = bit_size(LastInsertBin), + <> = LastInsertBin, + <> = FromBin, + <> = ToBin, + {ok, Map} = khepri_tx:get_many([network, NetworkID, #if_name_matches{regex = any}]), + NextIP = case LastInsert of + undefined -> + get_next(Map, [network, NetworkID], BitLength, From, To, From); + Payload -> + get_next(Map, [network, NetworkID], BitLength, From, To, Payload) + end, + case NextIP of + {ok, IP} -> + khepri_tx:put([network, NetworkID, <>], DomainID), + {ok, {Address, PrefixLen}, <>}; + Other -> + Other + end; + {error, ?khepri_error(node_not_found, _)} -> + {error, network_not_found} + end + end), + {reply, R, StoreId}; + +handle_call({ip_put, NetworkName, IPBlock, IPAddress}, _From, StoreId) -> + R = khepri:put(StoreId, [network, NetworkName, IPBlock, IPAddress], khepri_payload:none()), + {reply, R, StoreId}; + +handle_call({ip_clear}, _From, StoreId) -> + R = khepri:delete(StoreId, [network]), + {reply, R, StoreId}. + +handle_cast(Request, State) -> + erlang:error(not_implemented). + +start_server(StoreId) -> + gen_server:start_link({local, ipam}, ?MODULE, [StoreId], []). + +stop_server(Pid) -> + exit(Pid, normal). + +%% internal functions +get_next(Map, Path, BitLength, From, To, Start) -> + get_next(Map, Path, BitLength, From, To, Start, Start). + +get_next(Map, Path, BitLength, From, To, OriginalStart, Start) -> + case maps:is_key(Path ++ [<>], Map) of + true -> + Next = case Start of + To -> From; % wrap around + _ -> Start + 1 + end, + case Next of + OriginalStart -> + {error, no_ip_available}; + _ -> + get_next(Map, Path, BitLength, From, To, OriginalStart, Next) + end; + false -> + {ok, Start} + end. + + +get_range({_Address, PrefixLen}) -> + case _Address of + <> -> + io:format("IPv6~n", []), + get_range({Address, 128, PrefixLen}); + <> -> + io:format("IPv4~n", []), + get_range({Address, 32, PrefixLen}) + end; + +get_range({Address, AddressLength, PrefixLen}) -> + ShiftAmount = AddressLength - PrefixLen, + From = (Address bsr ShiftAmount) bsl ShiftAmount, + To = From + (1 bsl ShiftAmount) - 1, + io:format("From ~p to ~p~n", [From, To]), + io:format("From ~p to ~p~n", [<>, <>]), + {From, To}. + +subnet({_Address, PrefixLen}) -> + get_range({_Address, PrefixLen}). diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl new file mode 100644 index 0000000..9ed5c3f --- /dev/null +++ b/virtuerl/src/virtuerl_mgt.erl @@ -0,0 +1,118 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_mgt). + +-behaviour(gen_server). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). +-export([create_vm/0, domain_create/1, domain_get/1]). + +-define(SERVER, ?MODULE). + +create_vm() -> + gen_server:call(?SERVER, {domain_create, {default}}). + +%%create_vm(#{cpus := NumCPUs, memory := Memory}) -> +domain_create(Conf) -> + gen_server:call(?SERVER, {domain_create, Conf}). + +domain_delete(Conf) -> + gen_server:call(?SERVER, {domain_delete, Conf}). + +domain_get(Conf) -> + gen_server:call(?SERVER, {domain_get, Conf}). + +domains_list(Conf) -> + gen_server:call(?SERVER, {domains_list, Conf}). + + + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +-record(domain, {id, network_id, network_addr, ipv4_addr, tap_name}). + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + {ok, Table} = dets:open_file(vms, []), + virtuerl_ipam:ipam_put_net({default, <<192:8, 168:8, 10:8, 0:8>>, 28}), + application:ensure_all_started(grpcbox), + {ok, {Table}}. + +generate_unique_tap_name(TapNames) -> + TapName = io_lib:format("verltap~s", [binary:encode_hex(<<(rand:uniform(16#ffffff)):24>>)]), + case sets:is_element(TapName, TapNames) of + false -> + TapName; + true -> + generate_unique_tap_name(TapNames) + end. + +handle_call({domain_create, #{network_id := NetworkID}}, _From, State) -> + {Table} = State, + DomainID = binary:encode_hex(<<(rand:uniform(16#FFFFFFFF)-1):32>>), + Domain = #domain{id = DomainID, network_id = NetworkID}, + dets:insert_new(Table, {DomainID, Domain}), + dets:sync(Table), + {ok, Network, IP} = virtuerl_ipam:assign_next(NetworkID, DomainID), + Domains = dets:match_object(Table, '_'), + TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), + TapName = generate_unique_tap_name(TapNames), + dets:insert(Table, {DomainID, Domain#domain{network_addr =Network, ipv4_addr=IP, tap_name = TapName}}), + dets:sync(Table), + + gen_server:cast(virtuerl_net, {net_update}), + supervisor:start_child(virtuerl_sup, { + DomainID, + {virtuerl_qemu, start_link, [DomainID]}, + permanent, + infinity, + worker, + [] + }), + {reply, {ok, #{id => DomainID, tap_name => TapName, ip_addr => IP}}, State}; +handle_call({domain_get, #{id := DomainID}}, _From, State) -> + {Table} = State, + Reply = case dets:lookup(Table, DomainID) of + [{_, #domain{network_id = NetworkID, ipv4_addr=IP, tap_name = TapName}}] -> + DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip(IP)}, % , tap_name => TapName + {ok, DomRet}; + [] -> notfound + end, + {reply, Reply, State}. + +handle_cast(_Request, State) -> + {noreply, State}. + +handle_info(_Info, State) -> + {noreply, State}. + +terminate(_Reason, {Table}) -> + dets:close(Table), + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%%%=================================================================== +%%% Internal functions +%%%=================================================================== + +update_bird_conf(Table) -> + % 1. write config + %% for VM in VMs: + %% append VM.IP to static routes: VM.IP via $VM.network.bridge + % 2. birdc configure + % 3. profit? +%% VMs = dets:match_object(Table, '_'), +%% [io:format("~p~n", [VM]) || VM <- VMs]. + ok. diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl new file mode 100644 index 0000000..b1c9b58 --- /dev/null +++ b/virtuerl/src/virtuerl_net.erl @@ -0,0 +1,220 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_net). + +-behaviour(gen_server). + +-include_lib("kernel/include/logger.hrl"). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). +-export([parse_cidr/1, format_ip/1]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + ?LOG_INFO(#{what => "Started", who => virtuerl_net}), + {ok, Table} = dets:open_file(vms, []), + update_net(Table), + % TODO: erlexec: spawn bird -f + {ok, {Table}}. + +terminate(_Reason, {Table}) -> + dets:close(Table). + +handle_call({vm_create, Conf}, _From, State) -> + {reply, ok, State}. + +handle_cast({net_update}, State) -> + {Table} = State, + update_net(Table), + {noreply, State}. + +handle_info(_Info, State) -> + {noreply, State}. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%%%=================================================================== +%%% Internal functions +%%%=================================================================== + +startswith(Str, Pre) -> + case string:prefix(Str, Pre) of + nomatch -> false; + _ -> true + end. + +update_net(Table) -> + % 1. write config + %% for VM in VMs: + %% append VM.IP to static routes: VM.IP via $VM.network.bridge + % 2. birdc configure + % 3. profit? + Domains = dets:match_object(Table, '_'), + [io:format("~p~n", [Domain]) || Domain <- Domains], + reload_net(Table). + +-record(domain, {id, network_id, network_addr, ipv4_addr, tap_name}). + +handle_interface(If, Table) -> + %% 1. Delete all devices without an address set + Addrs = maps:get(<<"addr_info">>, If, []), + case Addrs of + [] -> os:cmd(io_lib:format("ip addr del ~p", [maps:get(<<"ifname">>, If)])) + end. + +get_cidr(If) -> + Addrs = maps:get(<<"addr_info">>, If, []), + Ifname = maps:get(<<"ifname">>, If), + case Addrs of + [] -> {unset, Ifname}; + [Something] -> {{parse_ip(maps:get(<<"local">>, Something)), maps:get(<<"prefixlen">>, Something)}, Ifname} + end. + +reload_net(Table) -> + Output = os:cmd("ip -j addr"), + {ok, JSON} = thoas:decode(Output), + io:format("~p~n", [JSON]), + Matched = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), +%% lists:foreach(fun(L) -> handle_interface(L, Table) end, Matched), + io:format("Actual: ~p~n", [Matched]), + Domains = dets:match_object(Table, '_'), + + TargetAddrs = sets:from_list([{bridge_addr(Addr), Prefixlen} || {_, #domain{network_addr = {Addr, Prefixlen}}} <- Domains]), + io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), + sync_networks(Matched, TargetAddrs), + sync_taps(Domains), + + update_bird_conf(Domains), + ok. + +bridge_addr(<>) -> + BitSize = bit_size(Addr), + <> = Addr, + <<(AddrInt+1):BitSize>>. + +parse_cidr(<>) -> parse_cidr(binary_to_list(CIDR)); +parse_cidr(CIDR) -> + [IP, Prefixlen] = string:split(CIDR, "/", trailing), + {I, _} = string:to_integer(Prefixlen), + {parse_ip(IP), I}. + +parse_ip(<>) -> parse_ip(binary_to_list(IP)); +parse_ip(IP) -> + {ok, Res} = inet:parse_address(IP), + case Res of + {A, B, C, D} -> <>; + {A, B, C, D, E, F, G, H} -> <> + end. + +format_ip(<>) -> + inet:ntoa({A, B, C, D}); +format_ip(<>) -> + inet:ntoa({A, B, C, D, E, F, G, H}). + +format_bird_route(<>) -> + io_lib:format("~s/~B", [format_ip(IP), bit_size(IP)]). + +build_routes(M) when is_map(M) -> build_routes(maps:to_list(M)); +build_routes([]) -> []; +build_routes([{Addr, Bridge}|L]) -> + [io_lib:format(" route ~s via \"~s\";", [format_bird_route(Addr), Bridge]) | build_routes(L)]. + +update_bird_conf(Domains) -> + Output = os:cmd("ip -j addr"), + {ok, JSON} = thoas:decode(Output), + Bridges = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), + AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #domain{network_addr = {NetAddr, Prefixlen}, ipv4_addr = Addr}} <- Domains]), + AddrToBridgeMap = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, AddrMap), + + io:format("DOMAINS: ~p~n", [Domains]), + io:format("AddrToBridgeMap: ~p~n", [AddrToBridgeMap]), + file:write_file("birderl.conf", lists:join("\n", + ["protocol static {", " ipv4;"] ++ build_routes(AddrToBridgeMap) ++ ["}\n"] )), + reload_bird(Domains). + +reload_bird(Domains) -> + ok. + +sync_networks(ActualAddrs, TargetAddrs) -> + Ifnames = sets:from_list([Name || {_, Name} <- maps:to_list(ActualAddrs)]), + ToDelete = maps:without(sets:to_list(TargetAddrs), ActualAddrs), + ToAdd = sets:subtract(TargetAddrs, sets:from_list(maps:keys(ActualAddrs))), + io:format("TO DELETE: ~p~n", [ToDelete]), + io:format("TO ADD: ~p~n", [sets:to_list(ToAdd)]), + maps:foreach(fun (_, V) -> + Cmd = io_lib:format("ip link del ~s~n", [V]), + io:format(Cmd), + os:cmd(Cmd) + end, ToDelete), + add_bridges(sets:to_list(ToAdd), Ifnames). + +add_bridges([], _) -> + ok; +add_bridges([{Addr,Prefixlen}|T], Ifnames) -> + Ifname = generate_unique_bridge_name(Ifnames), + Cmd = io_lib:format("ip link add name ~s type bridge~nip addr add ~s/~B dev ~s~n", [Ifname, format_ip(Addr), Prefixlen, Ifname]), + io:format(Cmd), + os:cmd(Cmd), + add_bridges(T, Ifnames), + ok. + + +generate_unique_bridge_name(Ifnames) -> + Ifname = io_lib:format("verlbr~s", [binary:encode_hex(<<(rand:uniform(16#ffffff)):24>>)]), + case sets:is_element(Ifname, Ifnames) of + false -> + Ifname; + true -> + generate_unique_bridge_name(Ifnames) + end. + + +sync_taps(Domains) -> + Output = os:cmd("ip -j addr"), + {ok, JSON} = thoas:decode(Output), + Bridges = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), + + OutputTaps = os:cmd("ip -j link"), + {ok, JSONTaps} = thoas:decode(OutputTaps), + io:format("TAPS: ~p~n", [JSONTaps]), + TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), + TapsTarget = sets:from_list([TapName || {_, #domain{tap_name = TapName}} <- Domains]), + io:format("Taps to add: ~p~n", [sets:to_list(TapsTarget)]), + TapsMap = maps:from_list([{Tap, {bridge_addr(Addr), Prefixlen}} || {_, #domain{network_addr = {Addr, Prefixlen}, tap_name = Tap}} <- Domains]), + + TapsToDelete = sets:subtract(TapsActual, TapsTarget), + lists:foreach(fun (E) -> + Cmd = io_lib:format("ip tuntap del ~s~n", [E]), + io:format(Cmd), + os:cmd(Cmd) +end, sets:to_list(TapsToDelete)), + + TapsToAdd = sets:subtract(TapsTarget, TapsActual), + + TapsMapsToAdd = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, maps:with(sets:to_list(TapsToAdd), TapsMap)), + add_taps(TapsMapsToAdd), + + ok. + + +add_taps(M) when is_map(M) -> add_taps(maps:to_list(M)); +add_taps([]) -> ok; +add_taps([{Tap, Bridge}|T]) -> + Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s master ~s~n", [Tap, Tap, Bridge]), + io:format(Cmd), + os:cmd(Cmd). diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl new file mode 100644 index 0000000..f7194e4 --- /dev/null +++ b/virtuerl/src/virtuerl_qemu.erl @@ -0,0 +1,70 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_qemu). + +-behaviour(gen_server). + +-export([start_link/1]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start_link(ID) -> +%% gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + Pid = spawn_link(fun() -> + io:format("QEMU: Starting VM with ID ~p~n", [ID]), + timer:sleep(20000), + io:format("QEMU: Exiting ~p~n", [ID]), + timer:sleep(500), + exit(failure) + + end), + {ok, Pid}. + +init([]) -> + {ok, Table} = dets:open_file(vms, []), + % TODO: erlexec: spawn bird -f + {ok, {Table}}. + +terminate(_Reason, {Table}) -> + dets:close(Table). + +handle_call({vm_create, Conf}, _From, State) -> + {reply, ok, State}. + +handle_cast({net_update}, State) -> + {Table} = State, + update_bird_conf(Table), + {noreply, State}. + +handle_info(_Info, State) -> + {noreply, State}. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%%%=================================================================== +%%% Internal functions +%%%=================================================================== + +update_bird_conf(Table) -> + % 1. write config + %% for VM in VMs: + %% append VM.IP to static routes: VM.IP via $VM.network.bridge + % 2. birdc configure + % 3. profit? + VMs = dets:match_object(Table, '_'), + [io:format("~p~n", [VM]) || VM <- VMs], + reload_bird(). + +reload_bird() -> + ok. diff --git a/virtuerl/src/virtuerl_sup.erl b/virtuerl/src/virtuerl_sup.erl new file mode 100644 index 0000000..ea41ed8 --- /dev/null +++ b/virtuerl/src/virtuerl_sup.erl @@ -0,0 +1,65 @@ +%%%------------------------------------------------------------------- +%% @doc virtuerl top level supervisor. +%% @end +%%%------------------------------------------------------------------- + +-module(virtuerl_sup). + +-behaviour(supervisor). + +-export([start_link/0]). + +-export([init/1]). + +-define(SERVER, ?MODULE). + +start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + +%% sup_flags() = #{strategy => strategy(), % optional +%% intensity => non_neg_integer(), % optional +%% period => pos_integer()} % optional +%% child_spec() = #{id => child_id(), % mandatory +%% start => mfargs(), % mandatory +%% restart => restart(), % optional +%% shutdown => shutdown(), % optional +%% type => worker(), % optional +%% modules => modules()} % optional +init([]) -> + SupFlags = #{strategy => one_for_one, + intensity => 3, + period => 5}, + ChildSpecs = [{ + virtuerl_ipam, + {virtuerl_ipam, start_link, []}, + permanent, + infinity, + worker, + [] + }, { + virtuerl_mgt, + {virtuerl_mgt, start_link, []}, + permanent, + infinity, + worker, + [] + }, { + virtuerl_net, + {virtuerl_net, start_link, []}, + permanent, + infinity, + worker, + [] + } + , { + virtuerl_api, + {virtuerl_api, start_link, []}, + permanent, + infinity, + worker, + [] + } + ], + {ok, {SupFlags, ChildSpecs}}. + +%% internal functions diff --git a/virtuerl/test/ipam.erl b/virtuerl/test/ipam.erl new file mode 100644 index 0000000..b448f90 --- /dev/null +++ b/virtuerl/test/ipam.erl @@ -0,0 +1,83 @@ +-module(ipam). +-include_lib("eunit/include/eunit.hrl"). +-include_lib("khepri/src/khepri_error.hrl"). + + +simple_test() -> + ?assert(0 == 0). + +fixture_test_() -> + {setup, + fun() -> + {ok, StoreId} = khepri:start("khepri-test", test), + {ok, Pid} = virtuerl_app:start_server(StoreId), + {StoreId, Pid} + end, + fun({StoreId, Pid}) -> + virtuerl_app:stop_server(Pid), + khepri:stop(StoreId), + case file:del_dir_r("khepri-test") of + {error, enoent} -> + ok; + ok -> + ok + end + end, + fun({StoreId, Pid}) -> + [ + {"network4", fun() -> network_test_4(StoreId) end}, + {"network6", fun() -> network_test_6(StoreId) end}, + {"test-me", fun() -> test_me(StoreId) end}, + {"test-me6", fun() -> test_me6(StoreId) end} + ] + end + }. + +network_test_4(StoreId) -> + NetId = <<"aabbcc">>, + {error, network_too_small} = virtuerl_app:ipam_put_net({NetId, <<192:8, 168:8, 10:8, 0:8>>, 29}), + {error, ?khepri_error(node_not_found, _)} = khepri:get(StoreId, [network, NetId]), + ok = khepri:delete(StoreId, [network, NetId]). + +network_test_6(StoreId) -> + NetId = <<"aabbcc">>, + {error, network_too_small} = virtuerl_app:ipam_put_net({NetId, <<16#20010db8000000000000000000000000:128>>, 125}), + {error, ?khepri_error(node_not_found, _)} = khepri:get(StoreId, [network, NetId]), + ok = khepri:delete(StoreId, [network, NetId]). + +test_me(StoreId) -> + NetId = <<"aabbcc">>, + {error, network_not_found} = virtuerl_app:ipam_next_ip(NetId), + ok = virtuerl_app:ipam_put_net({NetId, <<192:8, 168:8, 10:8, 0:8>>, 28}), +%% {ok, NextIP} = virtuerl_app:ipam_next_ip(NetId), + {ok, Net} = khepri:get(StoreId, [network, NetId]), + ?debugVal(Net), + {Time, {ok, NextIP}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(Time), + ?debugVal(NextIP), + ?assertEqual(<<192:8, 168:8, 10:8, 8:8>>, NextIP), + {TimeSecond, {ok, _}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(TimeSecond), + [{ok, _} = virtuerl_app:ipam_next_ip(NetId) || _ <- lists:seq(1, 6)], + {TimeLast, {error, no_ip_available}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(TimeLast), + ok = khepri:delete(StoreId, [network, NetId]). + +test_me6(StoreId) -> + NetId = <<"aabbcc">>, + {error, network_not_found} = virtuerl_app:ipam_next_ip(NetId), + ok = virtuerl_app:ipam_put_net({NetId, <<16#20010db8000000000000000000000000:128>>, 124}), +%% {ok, NextIP} = virtuerl_app:ipam_next_ip(NetId), + {ok, Net} = khepri:get(StoreId, [network, NetId]), + ?debugVal(Net), + {Time, {ok, NextIP}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(Time), + ?debugVal(NextIP), + ?assertEqual(<<16#20010db8000000000000000000000008:128>>, NextIP), + {TimeSecond, {ok, _}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(TimeSecond), + [{ok, _} = virtuerl_app:ipam_next_ip(NetId) || _ <- lists:seq(1, 6)], + {TimeLast, {error, no_ip_available}} = timer:tc(virtuerl_app, ipam_next_ip, [NetId]), + ?debugVal(TimeLast), + ok = khepri:delete(StoreId, [network, NetId]). + diff --git a/virtuerl/test/scheduler.erl b/virtuerl/test/scheduler.erl new file mode 100644 index 0000000..2f37601 --- /dev/null +++ b/virtuerl/test/scheduler.erl @@ -0,0 +1,6 @@ +-module(scheduler). +-include_lib("eunit/include/eunit.hrl"). + +simple_2_test() -> + ?assert(0==0). + diff --git a/virtuerl/virtuerl.iml b/virtuerl/virtuerl.iml new file mode 100644 index 0000000..fb381e8 --- /dev/null +++ b/virtuerl/virtuerl.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From f75ef6d0f6e9849e3df4027821cf2046b43f22e3 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 28 Aug 2023 19:43:17 +0200 Subject: [PATCH 02/51] virtuerl: add GET /networks endpoint --- virtuerl/src/virtuerl_api.erl | 7 ++++--- virtuerl/src/virtuerl_ipam.erl | 12 +++++++++++- virtuerl/src/virtuerl_mgt.erl | 2 +- virtuerl/src/virtuerl_net.erl | 4 +++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 0e795f1..44dd37f 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -40,7 +40,7 @@ start_link() -> urls() -> RawURLs = [ - {"^/networks/?$", networks, ['GET']}, + {"^/networks/?$", networks, ['GET', 'POST']}, {"^/networks/(?[^/]+)/?$", network, ['GET', 'PUT', 'DELETE']}, {"^/domains/?$", domains, ['GET', 'POST']}, {"^/domains/(?[^/]+)/?$", domain, ['GET']} @@ -118,8 +118,9 @@ parse_json(Req) -> JSON. handle(networks, 'GET', _, Req) -> -%% virtuerl_ipam:ipam_put_net({}), - mochiweb_request:ok({[], "HELLO\n"}, Req); + {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + io:format("~p~n", [Nets]), + mochiweb_request:respond({200, [{"Content-Type", "application/json"}], thoas:encode(Nets)}, Req); handle(networks, 'POST', _, Req) -> JSON = parse_json(Req), #{<<"network">> := #{<<"cidr">> := CIDR}} = JSON, diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 06b7cc2..2102836 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -7,7 +7,7 @@ -behavior(gen_server). --export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1]). +-export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0]). -include_lib("khepri/include/khepri.hrl"). -include_lib("khepri/src/khepri_error.hrl"). @@ -48,6 +48,9 @@ ipam_put_net(NetworkDef) -> Other end. +ipam_list_nets() -> + gen_server:call(ipam, net_list). + ipam_delete_net(ID) -> case gen_server:call(ipam, {net_delete, ID}) of {ok, Res} -> @@ -96,6 +99,13 @@ terminate(_Reason, StoreId) -> ok end. +handle_call(net_list, _From, StoreId) -> + case khepri:get_many(StoreId, [network, ?KHEPRI_WILDCARD_STAR]) of + {ok, Map} -> + Res = maps:from_list([{NetworkId, #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)]), + {reply, {ok, Res}, StoreId}; + Res -> {reply, Res, StoreId} + end; handle_call({net_put, Network}, _From, StoreId) -> {ID, Address, PrefixLen} = Network, {From, To} = get_range({Address, PrefixLen}), diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 9ed5c3f..6a0b9ca 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -84,7 +84,7 @@ handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of [{_, #domain{network_id = NetworkID, ipv4_addr=IP, tap_name = TapName}}] -> - DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip(IP)}, % , tap_name => TapName + DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip_bitstring(IP)}, % , tap_name => TapName {ok, DomRet}; [] -> notfound end, diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index b1c9b58..e40f779 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -13,7 +13,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --export([parse_cidr/1, format_ip/1]). +-export([parse_cidr/1, format_ip/1, format_ip_bitstring/1]). -define(SERVER, ?MODULE). @@ -125,6 +125,8 @@ format_ip(<>) -> inet:ntoa({A, B, C, D}); format_ip(<>) -> inet:ntoa({A, B, C, D, E, F, G, H}). +format_ip_bitstring(IP) -> + list_to_binary(format_ip(IP)). format_bird_route(<>) -> io_lib:format("~s/~B", [format_ip(IP), bit_size(IP)]). From 2c74061b7ae14dfe008573911475ad76a06b7944 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 28 Aug 2023 19:44:46 +0200 Subject: [PATCH 03/51] virtuerl: sync domains on start --- virtuerl/src/virtuerl_mgt.erl | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 6a0b9ca..26f7d5c 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -10,7 +10,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, - code_change/3]). + code_change/3, handle_continue/2]). -export([create_vm/0, domain_create/1, domain_get/1]). -define(SERVER, ?MODULE). @@ -44,9 +44,28 @@ start_link() -> init([]) -> {ok, Table} = dets:open_file(vms, []), - virtuerl_ipam:ipam_put_net({default, <<192:8, 168:8, 10:8, 0:8>>, 28}), - application:ensure_all_started(grpcbox), - {ok, {Table}}. +%% virtuerl_ipam:ipam_put_net({default, <<192:8, 168:8, 10:8, 0:8>>, 28}), +%% application:ensure_all_started(grpcbox), + {ok, {Table}, {continue, sync_domains}}. +%% {ok, {Table}}. + +handle_continue(sync_domains, State) -> + {Table} = State, + TargetDomains = sets:from_list([Id || {Id, _} <- dets:match_object(Table, '_')]), + RunningDomains = sets:from_list([Id || {Id, _, _, _} <- supervisor:which_children(virtuerl_sup), is_binary(Id)]), + ToDelete = sets:subtract(RunningDomains, TargetDomains), + ToAdd = sets:subtract(TargetDomains, RunningDomains), + [supervisor:delete_child(virtuerl_sup, Id) || Id <- sets:to_list(ToDelete)], + [ supervisor:start_child(virtuerl_sup, { + Id, + {virtuerl_qemu, start_link, [Id]}, + permanent, + infinity, + worker, + [] +}) || Id <- sets:to_list(ToAdd)], + {noreply, State}. + generate_unique_tap_name(TapNames) -> TapName = io_lib:format("verltap~s", [binary:encode_hex(<<(rand:uniform(16#ffffff)):24>>)]), From 629c2dfd2b833f7573b26e79740a9fb2c363d176 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 28 Aug 2023 19:45:46 +0200 Subject: [PATCH 04/51] virtuerl: add entrypoint for simplistic erl startup --- virtuerl/src/virtuerl_app.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_app.erl b/virtuerl/src/virtuerl_app.erl index ed8f686..db57f77 100644 --- a/virtuerl/src/virtuerl_app.erl +++ b/virtuerl/src/virtuerl_app.erl @@ -7,7 +7,7 @@ -behaviour(application). --export([start/2, stop/1]). +-export([start/2, stop/1, start/0]). %% app start/stop start(_StartType, _StartArgs) -> @@ -21,5 +21,8 @@ start(_StartType, _StartArgs) -> %% {ok, _} = Res, virtuerl_sup:start_link(). +start() -> + application:ensure_all_started(virtuerl). + stop(_State) -> ok. From 3198c685e011fccb61ba4b9ab99cd1da8f9c6e2f Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Thu, 31 Aug 2023 22:39:56 +0200 Subject: [PATCH 05/51] virtuerl: setup for integration test --- .github/workflows/build.yaml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0171721..be9172f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | sudo apt update - sudo apt install -y libvirt-dev + sudo apt install -y libvirt-dev rebar3 pip install -r requirements.txt -r requirements-dev.txt - name: Lint run: | @@ -36,6 +36,26 @@ jobs: sudo usermod --append --groups lxd $(whoami) sudo lxd init --auto snapcraft --use-lxd + - name: Setup Virtuerl + working-directory: virtuerl + run: | + sudo -s rebar3 compile + + cat << EOF | sudo tee -a /etc/systemd/system/virtuerl.service + [Unit] + Description=Virtuerl + After=network.target + + [Service] + WorkingDirectory=${PWD} + ExecStart=/bin/sh -c 'erl -pa _build/default/lib/*/ebin -config config/sys.config -s virtuerl_app -noshell -noinput' + Restart=always + + [Install] + WantedBy=multi-user.target + EOF + + sudo systemctl --now enable virtuerl - name: Integration Tests run: | sudo snap install --dangerous minivirt*.snap From 90caa11534d28a3a954443b654e7e36fc7e37fdd Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 16:17:18 +0200 Subject: [PATCH 06/51] virtuerl: use proper uuid4 for ids --- virtuerl/src/virtuerl_ipam.erl | 2 +- virtuerl/src/virtuerl_mgt.erl | 2 +- virtuerl/src/virtuerl_util.erl | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 virtuerl/src/virtuerl_util.erl diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 2102836..3bd0af8 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -37,7 +37,7 @@ req(Msg) -> ipam_create_net(NetworkDef) -> {Address, Prefixlen} = NetworkDef, - ID = binary:encode_hex(<<(rand:uniform(16#FFFFFFFF)-1):32>>), + ID = virtuerl_util:uuid4(), ipam_put_net({ID, Address, Prefixlen}). ipam_put_net(NetworkDef) -> diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 26f7d5c..8259daa 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -78,7 +78,7 @@ generate_unique_tap_name(TapNames) -> handle_call({domain_create, #{network_id := NetworkID}}, _From, State) -> {Table} = State, - DomainID = binary:encode_hex(<<(rand:uniform(16#FFFFFFFF)-1):32>>), + DomainID = virtuerl_util:uuid4(), Domain = #domain{id = DomainID, network_id = NetworkID}, dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), diff --git a/virtuerl/src/virtuerl_util.erl b/virtuerl/src/virtuerl_util.erl new file mode 100644 index 0000000..b06cad2 --- /dev/null +++ b/virtuerl/src/virtuerl_util.erl @@ -0,0 +1,19 @@ +%%%------------------------------------------------------------------- +%%% @author ilya-stroeer +%%% @copyright (C) 2023, +%%% @doc +%%% +%%% @end +%%% Created : 02. Sep 2023 4:05 PM +%%%------------------------------------------------------------------- +-module(virtuerl_util). +-author("ilya-stroeer"). + +%% API +-export([uuid4/0]). + +uuid4() -> + ID = string:lowercase(binary:encode_hex(<<(rand:uniform(16#FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)-1):128>>)), + <> = ID, + Uuid4 = iolist_to_binary([A, "-", B, "-", C, "-", D, "-", E]), + Uuid4. From cadbc04fdc38e44fddc0502abb7303fb4e7f76db Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 16:17:55 +0200 Subject: [PATCH 07/51] minivirt: integrate virtuerl --- minivirt/daemon.py | 42 +++++++++++++++++++++++++++++++++++++++++- requirements.txt | 1 + setup.py | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 6ad4171..0a33913 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -6,11 +6,13 @@ from datetime import datetime, timezone import libvirt +import requests import xmltodict from google.protobuf import empty_pb2, timestamp_pb2 from grpc import StatusCode from pyroute2 import IPRoute from pyroute2.netlink.rtnl import rtypes +from requests.exceptions import ConnectionError, HTTPError from sqlalchemy import delete, select from minivirt import ( @@ -336,6 +338,24 @@ def ListNetworks(self, request, context): def CreateNetwork(self, request, context): network = request.network + try: + net_json = {} + if network.cidr: + net_json["cidr4"] = network.cidr + if network.cidr6: + net_json["cidr6"] = network.cidr6 + res = requests.post( + "http://localhost:8080/networks", + json={"network": net_json}, + ) + res.raise_for_status() + virtuerl_net = res.json() + net_id = virtuerl_net["id"] + except ConnectionError as e: + net_id = uuid.uuid4() + except HTTPError as e: + raise e + nets = [network.cidr, network.cidr6] nets = [ipaddress.ip_network(net) for net in nets if net] assert len(nets), "no networks supplied" @@ -356,6 +376,7 @@ def to_family_string(net): lvnet = self.conn.networkDefineXML( f""" {network.name} + {net_id} {creation_timestamp.isoformat()} @@ -377,6 +398,9 @@ def DeleteNetwork(self, request, context): net = self.conn.networkLookupByUUIDString(request.uuid) net.destroy() net.undefine() + + requests.delete(f"http://localhost:8080/networks/{request.uuid}") + return empty_pb2.Empty() def StartDomain(self, request, context): @@ -428,6 +452,20 @@ def ListDomains(self, request, context): def CreateDomain(self, request, context): domreq = request.domain + try: + res = requests.post( + "http://localhost:8080/domains", json={"domain": {"network_id": domreq.network}} + ) + res.raise_for_status() + virtuerl_dom = res.json() + dom_id = virtuerl_dom["id"] + tap_name = virtuerl_dom["tap_name"] + print(f"TAP NAME: {tap_name}") + except ConnectionError as e: + dom_id = uuid.uuid4() + except HTTPError as e: + raise e + lvnet = self.conn.networkLookupByUUIDString(domreq.network) net_dict = xmltodict.parse(lvnet.XMLDesc(), force_list=("ip",)) net_def = net_dict["network"]["ip"][0] @@ -441,7 +479,7 @@ def CreateDomain(self, request, context): gateway6 = ipaddress.ip_address(net6_def["@address"]) net6 = ipaddress.ip_network(f'{gateway6}/{net6_def["@prefix"]}', strict=False) - dom_uuid = uuid.uuid4() + dom_uuid = dom_id os_type = domreq.os_type if os_type is None: os_type = "linux" @@ -620,6 +658,8 @@ def DeleteDomain(self, request, context): vol = pool.storageVolLookupByName(f"{name}-cloud-init.img") vol.delete() + requests.delete(f"http://localhost:8080/domains/{str(request.uuid)}") + return empty_pb2.Empty() def DownloadImage(self, request, context): diff --git a/requirements.txt b/requirements.txt index f062f4b..35bb0d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ xmltodict==0.12.0 dnslib==0.9.16 dnspython==2.2.1 PyYAML==6.0 +requests==2.31.0 diff --git a/setup.py b/setup.py index 312d35e..551e719 100644 --- a/setup.py +++ b/setup.py @@ -26,5 +26,6 @@ "dnslib==0.9.16", "dnspython==2.2.1", "PyYAML==6.0", + "requests==2.31.0", ], ) From d6ba2986311818c1368e9480e919163756611301 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 17:34:25 +0200 Subject: [PATCH 08/51] wait before register --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be9172f..2a1fb53 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -107,6 +107,8 @@ jobs: sudo snap start --enable minivirt.unbound sudo snap start --enable minivirt.controller + sleep 5 + sudo minivirt.register -a 127.0.0.1:8093 --name default -b 127.0.0.1:8099 --client-cert /var/snap/minivirt/common/server.crt --client-key /var/snap/minivirt/common/server.key --server-ca-cert /var/snap/minivirt/common/ca.crt sudo snap set minivirt daemon.args='--debug -a 127.0.0.1:8093 -b 127.0.0.1:8099 -c $SNAP_COMMON --client-cert $SNAP_COMMON/server.crt --client-key $SNAP_COMMON/server.key --server-ca-cert $SNAP_COMMON/ca.crt' sudo snap start --enable minivirt.daemon From 135a198d9e85300ef861075fc1933db70284652c Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 22:36:53 +0200 Subject: [PATCH 09/51] use more virtuerl networking --- minivirt/daemon.py | 88 +++++++++++++++++++++++------------ virtuerl/src/virtuerl_net.erl | 3 +- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 0a33913..19cb64a 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -380,6 +380,7 @@ def to_family_string(net): {creation_timestamp.isoformat()} + true @@ -391,13 +392,19 @@ def to_family_string(net): """ ) lvnet.create() - lvnet.setAutostart(True) + lvnet.destroy() return _network_to_pb(lvnet) def DeleteNetwork(self, request, context): - net = self.conn.networkLookupByUUIDString(request.uuid) - net.destroy() - net.undefine() + try: + net = self.conn.networkLookupByUUIDString(request.uuid) + try: + net.destroy() + except: + pass + net.undefine() + except: + pass requests.delete(f"http://localhost:8080/networks/{request.uuid}") @@ -452,32 +459,46 @@ def ListDomains(self, request, context): def CreateDomain(self, request, context): domreq = request.domain + req_net = {"domain": {"network_id": domreq.network}} + private_ip = domreq.private_ip + if private_ip: + req_net["domain"]["ipv4_addr"] = private_ip + ipv6_address = domreq.ipv6_address + try: - res = requests.post( - "http://localhost:8080/domains", json={"domain": {"network_id": domreq.network}} - ) + res = requests.post("http://localhost:8080/domains", json=req_net) res.raise_for_status() virtuerl_dom = res.json() dom_id = virtuerl_dom["id"] tap_name = virtuerl_dom["tap_name"] + ip_addr = virtuerl_dom["ip_addr"] print(f"TAP NAME: {tap_name}") - except ConnectionError as e: - dom_id = uuid.uuid4() except HTTPError as e: raise e - lvnet = self.conn.networkLookupByUUIDString(domreq.network) - net_dict = xmltodict.parse(lvnet.XMLDesc(), force_list=("ip",)) - net_def = net_dict["network"]["ip"][0] - gateway = ipaddress.ip_address(net_def["@address"]) - net = ipaddress.ip_network(f"{gateway}/{_network_prefix(net_def)}", strict=False) - gateway6 = None net6 = None - if len(net_dict["network"]["ip"]) > 1: - net6_def = net_dict["network"]["ip"][1] - gateway6 = ipaddress.ip_address(net6_def["@address"]) - net6 = ipaddress.ip_network(f'{gateway6}/{net6_def["@prefix"]}', strict=False) + + try: + lvnet = self.conn.networkLookupByUUIDString(domreq.network) + + net_dict = xmltodict.parse(lvnet.XMLDesc(), force_list=("ip",)) + net_def = net_dict["network"]["ip"][0] + gateway = ipaddress.ip_address(net_def["@address"]) + net = ipaddress.ip_network(f"{gateway}/{_network_prefix(net_def)}", strict=False) + + if len(net_dict["network"]["ip"]) > 1: + net6_def = net_dict["network"]["ip"][1] + gateway6 = ipaddress.ip_address(net6_def["@address"]) + net6 = ipaddress.ip_network(f'{gateway6}/{net6_def["@prefix"]}', strict=False) + + is_virtuerl_net = False + except libvirt.libvirtError as e: + if e.get_error_code() != libvirt.VIR_ERR_NO_NETWORK: + raise e + private_ip = ip_addr + + is_virtuerl_net = True dom_uuid = dom_id os_type = domreq.os_type @@ -486,8 +507,6 @@ def CreateDomain(self, request, context): user_data = domreq.user_data if user_data is None: user_data = "" - private_ip = domreq.private_ip - ipv6_address = domreq.ipv6_address with self.lock: with self.session_factory() as session: domains = session.execute(select(Domain)).scalars().all() @@ -513,6 +532,24 @@ def CreateDomain(self, request, context): ip = ipaddress.ip_address(private_ip) ip6 = ipaddress.ip_address(ipv6_address) if ipv6_address else None + mac = "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format( + 0x52, 0x54, 0x00, ip.packed[-3], ip.packed[-2], ip.packed[-1] + ) + + if is_virtuerl_net: + netxml = f""" + + + + +""" + else: + netxml = f""" + + + + +""" img_pool = self.conn.storagePoolLookupByName("restvirtimages") if not domreq.base_image: @@ -562,9 +599,6 @@ def CreateDomain(self, request, context): ) root_image_path = vol.path() - mac = "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format( - 0x52, 0x54, 0x00, ip.packed[-3], ip.packed[-2], ip.packed[-1] - ) ccfg_raw = create_cloud_config_image( domain_id=dom_uuid, user_data=user_data, @@ -621,11 +655,7 @@ def CreateDomain(self, request, context): - - - - - + {netxml} """ diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index e40f779..59b9114 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -219,4 +219,5 @@ add_taps([]) -> ok; add_taps([{Tap, Bridge}|T]) -> Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s master ~s~n", [Tap, Tap, Bridge]), io:format(Cmd), - os:cmd(Cmd). + os:cmd(Cmd), + add_taps(T). From fe599a3dfee52fbde13832b3f5e4c84d3a357c1b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 22:50:52 +0200 Subject: [PATCH 10/51] virtuerl: fix network rest cidr -> cidr4 --- virtuerl/src/virtuerl_api.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 44dd37f..1f1547f 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -123,7 +123,7 @@ handle(networks, 'GET', _, Req) -> mochiweb_request:respond({200, [{"Content-Type", "application/json"}], thoas:encode(Nets)}, Req); handle(networks, 'POST', _, Req) -> JSON = parse_json(Req), - #{<<"network">> := #{<<"cidr">> := CIDR}} = JSON, + #{<<"network">> := #{<<"cidr4">> := CIDR}} = JSON, {Addr, Prefixlen} = virtuerl_net:parse_cidr(CIDR), io:format("POST~n"), io:format("NetworkDef ~p/~p~n", [Addr, Prefixlen]), From 659dfa62ac702a216e996f0bf26c5e04aae19a6e Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 23:12:54 +0200 Subject: [PATCH 11/51] virtuerl: rest: return network id on create --- virtuerl/src/virtuerl_api.erl | 5 +++-- virtuerl/src/virtuerl_ipam.erl | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 1f1547f..1a07f4d 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -127,8 +127,9 @@ handle(networks, 'POST', _, Req) -> {Addr, Prefixlen} = virtuerl_net:parse_cidr(CIDR), io:format("POST~n"), io:format("NetworkDef ~p/~p~n", [Addr, Prefixlen]), - virtuerl_ipam:ipam_create_net({Addr, Prefixlen}), - mochiweb_request:ok({[], "HELLO\n"}, Req); + {ok, {ID, _, _}} = virtuerl_ipam:ipam_create_net({Addr, Prefixlen}), + RespJSON = thoas:encode(#{id => ID}), + mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/networks/" ++ binary_to_list(ID)}], RespJSON}, Req); handle(network, 'PUT', #{id := ID}, Req) -> JSON = parse_json(Req), #{<<"network">> := #{<<"cidr">> := CIDR}} = JSON, diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 3bd0af8..0b7aea5 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -42,8 +42,8 @@ ipam_create_net(NetworkDef) -> ipam_put_net(NetworkDef) -> case gen_server:call(ipam, {net_put, NetworkDef}) of - {ok, Res} -> - Res; + ok -> + {ok, NetworkDef}; Other -> Other end. From 3e809aebcf6ce4231c024c2119ee38823bf62f7d Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 23:29:48 +0200 Subject: [PATCH 12/51] don't create a libvirt net --- minivirt/daemon.py | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 19cb64a..b60560c 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -351,49 +351,15 @@ def CreateNetwork(self, request, context): res.raise_for_status() virtuerl_net = res.json() net_id = virtuerl_net["id"] - except ConnectionError as e: - net_id = uuid.uuid4() except HTTPError as e: raise e - nets = [network.cidr, network.cidr6] - nets = [ipaddress.ip_network(net) for net in nets if net] - assert len(nets), "no networks supplied" - - def to_family_string(net): - if isinstance(net, ipaddress.IPv4Network): - return "ipv4" - elif isinstance(net, ipaddress.IPv6Network): - return "ipv6" - else: - assert False, "unknown ip familiy" - - netdefs = [ - f"" - for net in nets - ] - creation_timestamp = datetime.now(timezone.utc) - lvnet = self.conn.networkDefineXML( - f""" - {network.name} - {net_id} - - - {creation_timestamp.isoformat()} - true - - - - - - -{chr(10).join(netdefs)} - -""" + return domain_pb2.Network( + uuid=net_id, + name="name", + cidr=network.cidr, + cidr6=network.cidr6, ) - lvnet.create() - lvnet.destroy() - return _network_to_pb(lvnet) def DeleteNetwork(self, request, context): try: From f597023c4a5f4d654230151bca7a7c20f4bff044 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 2 Sep 2023 23:54:11 +0200 Subject: [PATCH 13/51] virtuerl: fix json response encoding --- virtuerl/src/virtuerl_api.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 1a07f4d..8c1ac70 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -151,7 +151,7 @@ handle(domains, 'POST', _, Req) -> #{<<"domain">> := #{<<"network_id">> := NetworkID}} = JSON, {ok, Resp} = virtuerl_mgt:domain_create(#{network_id => NetworkID}), #{id := DomainID, tap_name := TapName, ip_addr := IP} = Resp, - RespJSON = thoas:encode(#{id => DomainID, tap_name => TapName, ip_addr => virtuerl_net:format_ip(IP)}), + RespJSON = thoas:encode(#{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => iolist_to_binary(virtuerl_net:format_ip(IP))}), mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/domains/" ++ binary_to_list(DomainID)}], RespJSON}, Req); handle(domain, 'GET', #{id := ID}, Req) -> io:format("DOMAIN GET: ~p~n", [ID]), From e1fc72c25b4efaece370b5221f0b39f341d8212e Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 3 Sep 2023 20:10:47 +0200 Subject: [PATCH 14/51] virtuerl: api: implement GET /networks/ --- minivirt/daemon.py | 5 +++++ virtuerl/src/virtuerl_api.erl | 4 +++- virtuerl/src/virtuerl_ipam.erl | 13 ++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index b60560c..4f6dfd5 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -464,6 +464,11 @@ def CreateDomain(self, request, context): raise e private_ip = ip_addr + vres = requests.get(f"http://localhost:8080/networks/{domreq.network}") + vres.raise_for_status() + vresj = vres.json() + net = ipaddress.ip_network(vresj["cidr4"], strict=False) + is_virtuerl_net = True dom_uuid = dom_id diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 8c1ac70..cc7a721 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -140,7 +140,9 @@ handle(network, 'PUT', #{id := ID}, Req) -> mochiweb_request:ok({[], "HELLO\n"}, Req); handle(network, 'GET', #{id := ID}, Req) -> io:format("GET: ~p~n", [ID]), - mochiweb_request:ok({[], "HELLO\n"}, Req); + {ok, Net} = virtuerl_ipam:ipam_get_net(list_to_binary(ID)), + RespJson = thoas:encode(Net), + mochiweb_request:respond({200, [{"Content-Type", "application/json"}], RespJson}, Req); handle(network, 'DELETE', #{id := ID}, Req) -> io:format("DELETE: ~p~n", [ID]), ok = virtuerl_ipam:ipam_delete_net(list_to_binary(ID)), diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 0b7aea5..d6c8c8d 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -7,7 +7,7 @@ -behavior(gen_server). --export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0]). +-export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1]). -include_lib("khepri/include/khepri.hrl"). -include_lib("khepri/src/khepri_error.hrl"). @@ -59,6 +59,15 @@ ipam_delete_net(ID) -> Other end. +ipam_get_net(Id) -> + case gen_server:call(ipam, {net_get, Id}) of + {ok, #network{address = Address, prefixlen = PrefixLen}} -> + Cidr4 = iolist_to_binary([virtuerl_net:format_ip_bitstring(Address), "/", integer_to_binary(PrefixLen)]), + Res = #{id => Id, cidr4 => Cidr4}, + {ok, Res}; + Other -> Other + end. + ipam_put_ip(NetworkName, IP) -> gen_server:call(ipam, {ip_put, NetworkName, IP}). @@ -106,6 +115,8 @@ handle_call(net_list, _From, StoreId) -> {reply, {ok, Res}, StoreId}; Res -> {reply, Res, StoreId} end; +handle_call({net_get, NetworkId}, _From, StoreId) -> + {reply, khepri:get(StoreId, [network, NetworkId]), StoreId}; handle_call({net_put, Network}, _From, StoreId) -> {ID, Address, PrefixLen} = Network, {From, To} = get_range({Address, PrefixLen}), From a5f1175df5d7836c45f0ffae491c8c345d26ee34 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 3 Sep 2023 20:33:53 +0200 Subject: [PATCH 15/51] virtuerl: sup: increase intensity --- virtuerl/src/virtuerl_sup.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_sup.erl b/virtuerl/src/virtuerl_sup.erl index ea41ed8..fec95ef 100644 --- a/virtuerl/src/virtuerl_sup.erl +++ b/virtuerl/src/virtuerl_sup.erl @@ -27,7 +27,7 @@ start_link() -> %% modules => modules()} % optional init([]) -> SupFlags = #{strategy => one_for_one, - intensity => 3, + intensity => 300, period => 5}, ChildSpecs = [{ virtuerl_ipam, From 746546929f74455fa62c323dd4f11c9f60a26f6b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 3 Sep 2023 21:40:13 +0200 Subject: [PATCH 16/51] minivirt: use network info from virtuerl --- minivirt/daemon.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 4f6dfd5..7eca266 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -55,9 +55,12 @@ def domain_to_dict(domain): "name": d["name"], "vcpu": int(d["vcpu"]["#text"]), "memory": int(d["memory"]["#text"]) // 1024, - "network": d["devices"]["interface"]["source"]["@network"], "nested_virtualization": d["cpu"]["@mode"] == "host-model", } + try: + res["network"] = d["devices"]["interface"]["source"]["@network"] + except: + pass try: # FIXME: once all have create metadata, remove this try/catch dt = datetime.fromisoformat(d["metadata"]["restvirt:metadata"]["created"]) res["created_at"] = timestamp_pb2.Timestamp( @@ -392,8 +395,13 @@ def StopDomain(self, request, context): def _get_domain(self, uuid): domain_lv = self.conn.lookupByUUIDString(uuid) domain_dict = domain_to_dict(domain_lv) - net = self.conn.networkLookupByName(domain_dict["network"]) - domain_dict["network"] = net.UUIDString() + try: + net = self.conn.networkLookupByName(domain_dict["network"]) + domain_dict["network"] = net.UUIDString() + except: + res = requests.get(f"http://localhost:8080/domains/{uuid}") + resj = res.json() + domain_dict["network"] = resj["network_id"] state, _ = domain_lv.state() domain_dict["state"] = libvirt_state_to_string(state) From 8c10c507abbdb3d766b47effbbe462e485f516d8 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 4 Sep 2023 18:31:30 +0200 Subject: [PATCH 17/51] virtuerl: api: add domain creation with fixed ip --- virtuerl/src/virtuerl_api.erl | 7 ++++++- virtuerl/src/virtuerl_ipam.erl | 10 +++++----- virtuerl/src/virtuerl_mgt.erl | 18 +++++++++++++----- virtuerl/src/virtuerl_net.erl | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index cc7a721..11d0221 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -151,7 +151,12 @@ handle(network, 'DELETE', #{id := ID}, Req) -> handle(domains, 'POST', _, Req) -> JSON = parse_json(Req), #{<<"domain">> := #{<<"network_id">> := NetworkID}} = JSON, - {ok, Resp} = virtuerl_mgt:domain_create(#{network_id => NetworkID}), + {ok, Resp} = case JSON of + #{<<"domain">> := #{<<"ipv4_addr">> := Ipv4Addr}} -> + virtuerl_mgt:domain_create(#{network_id => NetworkID, ipv4_addr => Ipv4Addr}); + _ -> + virtuerl_mgt:domain_create(#{network_id => NetworkID}) + end, #{id := DomainID, tap_name := TapName, ip_addr := IP} = Resp, RespJSON = thoas:encode(#{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => iolist_to_binary(virtuerl_net:format_ip(IP))}), mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/domains/" ++ binary_to_list(DomainID)}], RespJSON}, Req); diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index d6c8c8d..dfa98ef 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -7,7 +7,7 @@ -behavior(gen_server). --export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_put_ip/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1]). +-export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1, ipam_put_ip/3]). -include_lib("khepri/include/khepri.hrl"). -include_lib("khepri/src/khepri_error.hrl"). @@ -68,8 +68,8 @@ ipam_get_net(Id) -> Other -> Other end. -ipam_put_ip(NetworkName, IP) -> - gen_server:call(ipam, {ip_put, NetworkName, IP}). +ipam_put_ip(NetworkName, IP, DomainId) -> + gen_server:call(ipam, {ip_put, NetworkName, IP, DomainId}). assign_next(NetworkID, VMID) -> case gen_server:call(ipam, {ip_next, NetworkID, VMID}) of @@ -162,8 +162,8 @@ handle_call({ip_next, NetworkID, DomainID}, _From, StoreId) -> end), {reply, R, StoreId}; -handle_call({ip_put, NetworkName, IPBlock, IPAddress}, _From, StoreId) -> - R = khepri:put(StoreId, [network, NetworkName, IPBlock, IPAddress], khepri_payload:none()), +handle_call({ip_put, NetworkId, IpAddr, DomainId}, _From, StoreId) -> + R = khepri:create(StoreId, [network, NetworkId, IpAddr], DomainId), {reply, R, StoreId}; handle_call({ip_clear}, _From, StoreId) -> diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 8259daa..b3680e9 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -76,13 +76,21 @@ generate_unique_tap_name(TapNames) -> generate_unique_tap_name(TapNames) end. -handle_call({domain_create, #{network_id := NetworkID}}, _From, State) -> +handle_call({domain_create, Conf}, _From, State) -> {Table} = State, + #{network_id := NetworkID} = Conf, DomainID = virtuerl_util:uuid4(), - Domain = #domain{id = DomainID, network_id = NetworkID}, + Domain = #domain{id = DomainID, network_id = NetworkID}, % TODO: save ipv4 addr as well dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), - {ok, Network, IP} = virtuerl_ipam:assign_next(NetworkID, DomainID), + {ok, Network, IP} = case Conf of + #{ipv4_addr := Ipv4Addr} -> + Ipv4Addr1 = virtuerl_net:parse_ip(Ipv4Addr), + ok = virtuerl_ipam:ipam_put_ip(NetworkID, Ipv4Addr1, DomainID), + {ok, NetworkID, Ipv4Addr1}; + _ -> + virtuerl_ipam:assign_next(NetworkID, DomainID) + end, Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), @@ -98,12 +106,12 @@ handle_call({domain_create, #{network_id := NetworkID}}, _From, State) -> worker, [] }), - {reply, {ok, #{id => DomainID, tap_name => TapName, ip_addr => IP}}, State}; + {reply, {ok, #{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => IP}}, State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of [{_, #domain{network_id = NetworkID, ipv4_addr=IP, tap_name = TapName}}] -> - DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip_bitstring(IP)}, % , tap_name => TapName + DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip_bitstring(IP), tap_name => iolist_to_binary(TapName)}, {ok, DomRet}; [] -> notfound end, diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 59b9114..fc6e709 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -13,7 +13,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --export([parse_cidr/1, format_ip/1, format_ip_bitstring/1]). +-export([parse_cidr/1, format_ip/1, format_ip_bitstring/1, parse_ip/1]). -define(SERVER, ?MODULE). From 4dbec687982472e1bb29c8c1d2ce25e7132f9ffe Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 4 Sep 2023 19:26:52 +0200 Subject: [PATCH 18/51] virtuerl: properly delete tap devices --- virtuerl/src/virtuerl_net.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index fc6e709..b0c98c3 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -201,7 +201,7 @@ sync_taps(Domains) -> TapsToDelete = sets:subtract(TapsActual, TapsTarget), lists:foreach(fun (E) -> - Cmd = io_lib:format("ip tuntap del ~s~n", [E]), + Cmd = io_lib:format("ip link del ~s~n", [E]), io:format(Cmd), os:cmd(Cmd) end, sets:to_list(TapsToDelete)), From c5aa0202435dcf809b469d97c1da0e8798171c09 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 4 Sep 2023 19:27:50 +0200 Subject: [PATCH 19/51] virtuerl: update network synchronously --- virtuerl/src/virtuerl_mgt.erl | 2 +- virtuerl/src/virtuerl_net.erl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index b3680e9..40830df 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -97,7 +97,7 @@ handle_call({domain_create, Conf}, _From, State) -> dets:insert(Table, {DomainID, Domain#domain{network_addr =Network, ipv4_addr=IP, tap_name = TapName}}), dets:sync(Table), - gen_server:cast(virtuerl_net, {net_update}), + gen_server:call(virtuerl_net, {net_update}), supervisor:start_child(virtuerl_sup, { DomainID, {virtuerl_qemu, start_link, [DomainID]}, diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index b0c98c3..aca88e2 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -35,6 +35,11 @@ terminate(_Reason, {Table}) -> dets:close(Table). handle_call({vm_create, Conf}, _From, State) -> + {reply, ok, State}; + +handle_call({net_update}, _From, State) -> + {Table} = State, + update_net(Table), {reply, ok, State}. handle_cast({net_update}, State) -> From ad27c36fd6fa744055c7837f0bbbeada3c1cbe19 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 4 Sep 2023 22:44:39 +0200 Subject: [PATCH 20/51] virtuerl: return network when creating dom with fixed ip --- virtuerl/src/virtuerl_ipam.erl | 12 +++++++++++- virtuerl/src/virtuerl_mgt.erl | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index dfa98ef..4ccac8d 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -163,7 +163,17 @@ handle_call({ip_next, NetworkID, DomainID}, _From, StoreId) -> {reply, R, StoreId}; handle_call({ip_put, NetworkId, IpAddr, DomainId}, _From, StoreId) -> - R = khepri:create(StoreId, [network, NetworkId, IpAddr], DomainId), + R = case khepri:get([network, NetworkId]) of + {ok, Network} -> + #network{address = Address, prefixlen = PrefixLen} = Network, + case khepri:create(StoreId, [network, NetworkId, IpAddr], DomainId) of + ok -> + {ok, {Address, PrefixLen}}; + Other -> Other + end; + {error, ?khepri_error(node_not_found, _)} -> + {error, network_not_found} + end, {reply, R, StoreId}; handle_call({ip_clear}, _From, StoreId) -> diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 40830df..0ef9016 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -86,8 +86,8 @@ handle_call({domain_create, Conf}, _From, State) -> {ok, Network, IP} = case Conf of #{ipv4_addr := Ipv4Addr} -> Ipv4Addr1 = virtuerl_net:parse_ip(Ipv4Addr), - ok = virtuerl_ipam:ipam_put_ip(NetworkID, Ipv4Addr1, DomainID), - {ok, NetworkID, Ipv4Addr1}; + {ok, NetRes} = virtuerl_ipam:ipam_put_ip(NetworkID, Ipv4Addr1, DomainID), + {ok, NetRes, Ipv4Addr1}; _ -> virtuerl_ipam:assign_next(NetworkID, DomainID) end, @@ -97,7 +97,7 @@ handle_call({domain_create, Conf}, _From, State) -> dets:insert(Table, {DomainID, Domain#domain{network_addr =Network, ipv4_addr=IP, tap_name = TapName}}), dets:sync(Table), - gen_server:call(virtuerl_net, {net_update}), + ok = gen_server:call(virtuerl_net, {net_update}), supervisor:start_child(virtuerl_sup, { DomainID, {virtuerl_qemu, start_link, [DomainID]}, From 097ba282c639f9157c81c14b1ba09ed6f73d694d Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 10 Sep 2023 19:16:26 +0200 Subject: [PATCH 21/51] virtuerl: add support for ipv6 --- minivirt/daemon.py | 10 +++- virtuerl/src/virtuerl_api.erl | 22 +++++++-- virtuerl/src/virtuerl_ipam.erl | 83 ++++++++++++++++++++++------------ virtuerl/src/virtuerl_mgt.erl | 38 +++++++++++----- virtuerl/src/virtuerl_net.erl | 26 ++++++----- 5 files changed, 122 insertions(+), 57 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 7eca266..4dd47f6 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -438,6 +438,8 @@ def CreateDomain(self, request, context): if private_ip: req_net["domain"]["ipv4_addr"] = private_ip ipv6_address = domreq.ipv6_address + if ipv6_address: + req_net["domain"]["ipv6_addr"] = ipv6_address try: res = requests.post("http://localhost:8080/domains", json=req_net) @@ -445,8 +447,8 @@ def CreateDomain(self, request, context): virtuerl_dom = res.json() dom_id = virtuerl_dom["id"] tap_name = virtuerl_dom["tap_name"] - ip_addr = virtuerl_dom["ip_addr"] - print(f"TAP NAME: {tap_name}") + ip_addr = virtuerl_dom["ipv4_addr"] + ip6_addr = virtuerl_dom["ipv6_addr"] except HTTPError as e: raise e @@ -476,6 +478,10 @@ def CreateDomain(self, request, context): vres.raise_for_status() vresj = vres.json() net = ipaddress.ip_network(vresj["cidr4"], strict=False) + gateway = net[1] + if ipv6_address: + net6 = ipaddress.ip_network(vresj["cidr6"], strict=False) + gateway6 = net6[1] is_virtuerl_net = True diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 11d0221..ca6b52e 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -123,11 +123,25 @@ handle(networks, 'GET', _, Req) -> mochiweb_request:respond({200, [{"Content-Type", "application/json"}], thoas:encode(Nets)}, Req); handle(networks, 'POST', _, Req) -> JSON = parse_json(Req), - #{<<"network">> := #{<<"cidr4">> := CIDR}} = JSON, - {Addr, Prefixlen} = virtuerl_net:parse_cidr(CIDR), + #{<<"network">> := NetJson} = JSON, + {ok, NetDefs} = case NetJson of + #{<<"cidr4">> := Cidr4, <<"cidr6">> := Cidr6} -> + {Addr4, Prefixlen4} = virtuerl_net:parse_cidr(Cidr4), + {Addr6, Prefixlen6} = virtuerl_net:parse_cidr(Cidr6), + {ok, [{Addr4, Prefixlen4}, {Addr6, Prefixlen6}]}; + #{<<"cidr4">> := Cidr4} -> + {Addr4, Prefixlen4} = virtuerl_net:parse_cidr(Cidr4), + {ok, [{Addr4, Prefixlen4}]}; + #{<<"cidr6">> := Cidr6} -> + {Addr6, Prefixlen6} = virtuerl_net:parse_cidr(Cidr6), + {ok, [{Addr6, Prefixlen6}]}; + _ -> + {error, no_cidrs_provided} + end, + io:format("POST~n"), - io:format("NetworkDef ~p/~p~n", [Addr, Prefixlen]), - {ok, {ID, _, _}} = virtuerl_ipam:ipam_create_net({Addr, Prefixlen}), + io:format("NetworkDefs ~p~n", [NetDefs]), + {ok, ID} = virtuerl_ipam:ipam_create_net(NetDefs), RespJSON = thoas:encode(#{id => ID}), mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/networks/" ++ binary_to_list(ID)}], RespJSON}, Req); handle(network, 'PUT', #{id := ID}, Req) -> diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 4ccac8d..163dc8a 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -7,7 +7,7 @@ -behavior(gen_server). --export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, assign_next/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1, ipam_put_ip/3]). +-export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1, ipam_put_ip/3, assign_next/3]). -include_lib("khepri/include/khepri.hrl"). -include_lib("khepri/src/khepri_error.hrl"). @@ -36,9 +36,8 @@ req(Msg) -> -record(network, {last_insert, from, to, address, prefixlen}). ipam_create_net(NetworkDef) -> - {Address, Prefixlen} = NetworkDef, ID = virtuerl_util:uuid4(), - ipam_put_net({ID, Address, Prefixlen}). + ipam_put_net({ID, NetworkDef}). ipam_put_net(NetworkDef) -> case gen_server:call(ipam, {net_put, NetworkDef}) of @@ -61,18 +60,21 @@ ipam_delete_net(ID) -> ipam_get_net(Id) -> case gen_server:call(ipam, {net_get, Id}) of - {ok, #network{address = Address, prefixlen = PrefixLen}} -> - Cidr4 = iolist_to_binary([virtuerl_net:format_ip_bitstring(Address), "/", integer_to_binary(PrefixLen)]), - Res = #{id => Id, cidr4 => Cidr4}, + {ok, Pools} -> + io:format("POOLS: ~p~n", [Pools]), + Cidrs = [iolist_to_binary([Address, "/", integer_to_binary(Prefixlen)]) || #{address := Address, prefixlen := Prefixlen} <- maps:values(Pools)], + Res = #{id => Id, cidrs => Cidrs}, {ok, Res}; - Other -> Other + Other -> + io:format("Error ~p~n", [Other]), + Other end. ipam_put_ip(NetworkName, IP, DomainId) -> gen_server:call(ipam, {ip_put, NetworkName, IP, DomainId}). -assign_next(NetworkID, VMID) -> - case gen_server:call(ipam, {ip_next, NetworkID, VMID}) of +assign_next(NetworkID, Tag, VMID) -> + case gen_server:call(ipam, {ip_next, NetworkID, Tag, VMID}) of {ok, Res} -> Res; Other -> @@ -109,49 +111,68 @@ terminate(_Reason, StoreId) -> end. handle_call(net_list, _From, StoreId) -> - case khepri:get_many(StoreId, [network, ?KHEPRI_WILDCARD_STAR]) of + case khepri:get_many(StoreId, [network, ?KHEPRI_WILDCARD_STAR, ?KHEPRI_WILDCARD_STAR]) of {ok, Map} -> - Res = maps:from_list([{NetworkId, #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)]), + ToMapKey = fun(Tag) -> case Tag of ipv4 -> cidr4; ipv6 -> cidr6 end end, + Res0 = [{NetworkId, ToMapKey(Tag), #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId, Tag], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)], + Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), + Res = maps:map(fun(_, V) -> maps:from_list(V) end, Res1), {reply, {ok, Res}, StoreId}; Res -> {reply, Res, StoreId} end; handle_call({net_get, NetworkId}, _From, StoreId) -> - {reply, khepri:get(StoreId, [network, NetworkId]), StoreId}; + case khepri:get_many(StoreId, [network, NetworkId, ?KHEPRI_WILDCARD_STAR]) of + {ok, Map} -> + ToMapKey = fun(Tag) -> case Tag of ipv4 -> cidr4; ipv6 -> cidr6 end end, + Res0 = [{NetworkId, ToMapKey(Tag), #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId, Tag], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)], + Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), + #{NetworkId := Res} = maps:map(fun(_, V) -> maps:from_list(V) end, Res1), + {reply, {ok, Res}, StoreId}; + Res -> {reply, Res, StoreId} + end; handle_call({net_put, Network}, _From, StoreId) -> - {ID, Address, PrefixLen} = Network, - {From, To} = get_range({Address, PrefixLen}), - case To - From =< 8 of - false -> - BitLength = bit_size(Address), - ok = khepri:put(StoreId, [network, ID], #network{address = Address, prefixlen = PrefixLen, from= <<(From+8):BitLength>>, to= <>, last_insert= <<(From+8):BitLength>>}), - {reply, ok, StoreId}; - true -> + {ID, Defs} = Network, + Ranges = [get_range({Address, PrefixLen}) || {Address, PrefixLen} <- Defs], + TooSmallNets = [too_small || {From, To} <- Ranges, To - From =< 8], + case TooSmallNets of + [] -> + InsertNet = fun({Address, Prefixlen}) -> + {From, To} = get_range({Address, Prefixlen}), + BitLength = bit_size(Address), + Tag = case BitLength of + 32 -> ipv4; + 128 -> ipv6 + end, + ok = khepri:put(StoreId, [network, ID, Tag], #network{address = Address, prefixlen = Prefixlen, from = <<(From + 8):BitLength>>, to = <>, last_insert = <<(From + 8):BitLength>>}) + end, + lists:foreach(InsertNet, Defs), + {reply, {ok, ID}, StoreId}; + _ -> {reply, {error, network_too_small}, StoreId} end; handle_call({net_delete, ID}, _From, StoreId) -> Ret = khepri:delete(StoreId, [network, ID]), {reply, Ret, StoreId}; -handle_call({ip_next, NetworkID}, _From, StoreId) -> handle_call({ip_next, NetworkID, ""}, _From, StoreId); -handle_call({ip_next, NetworkID, DomainID}, _From, StoreId) -> +handle_call({ip_next, NetworkID, Tag, DomainID}, _From, StoreId) -> R = khepri:transaction(StoreId, fun() -> - case khepri_tx:get([network, NetworkID]) of + case khepri_tx:get([network, NetworkID, Tag]) of {ok, Network} -> #network{address = Address, prefixlen = PrefixLen, last_insert= LastInsertBin, from= FromBin, to= ToBin} = Network, BitLength = bit_size(LastInsertBin), <> = LastInsertBin, <> = FromBin, <> = ToBin, - {ok, Map} = khepri_tx:get_many([network, NetworkID, #if_name_matches{regex = any}]), + {ok, Map} = khepri_tx:get_many([network, NetworkID, Tag, #if_name_matches{regex = any}]), NextIP = case LastInsert of undefined -> - get_next(Map, [network, NetworkID], BitLength, From, To, From); + get_next(Map, [network, NetworkID, Tag], BitLength, From, To, From); Payload -> - get_next(Map, [network, NetworkID], BitLength, From, To, Payload) + get_next(Map, [network, NetworkID, Tag], BitLength, From, To, Payload) end, case NextIP of {ok, IP} -> - khepri_tx:put([network, NetworkID, <>], DomainID), + khepri_tx:put([network, NetworkID, Tag, <>], DomainID), {ok, {Address, PrefixLen}, <>}; Other -> Other @@ -163,10 +184,14 @@ handle_call({ip_next, NetworkID, DomainID}, _From, StoreId) -> {reply, R, StoreId}; handle_call({ip_put, NetworkId, IpAddr, DomainId}, _From, StoreId) -> - R = case khepri:get([network, NetworkId]) of + Tag = case bit_size(IpAddr) of + 32 -> ipv4; + 128 -> ipv6 + end, + R = case khepri:get([network, NetworkId, Tag]) of {ok, Network} -> #network{address = Address, prefixlen = PrefixLen} = Network, - case khepri:create(StoreId, [network, NetworkId, IpAddr], DomainId) of + case khepri:create(StoreId, [network, NetworkId, Tag, IpAddr], DomainId) of ok -> {ok, {Address, PrefixLen}}; Other -> Other diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 0ef9016..4e75800 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -37,7 +37,7 @@ domains_list(Conf) -> %%% Spawning and gen_server implementation %%%=================================================================== --record(domain, {id, network_id, network_addr, ipv4_addr, tap_name}). +-record(domain, {id, network_id, network_addrs, ipv4_addr, ipv6_addr, tap_name}). start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). @@ -83,18 +83,34 @@ handle_call({domain_create, Conf}, _From, State) -> Domain = #domain{id = DomainID, network_id = NetworkID}, % TODO: save ipv4 addr as well dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), - {ok, Network, IP} = case Conf of - #{ipv4_addr := Ipv4Addr} -> - Ipv4Addr1 = virtuerl_net:parse_ip(Ipv4Addr), - {ok, NetRes} = virtuerl_ipam:ipam_put_ip(NetworkID, Ipv4Addr1, DomainID), - {ok, NetRes, Ipv4Addr1}; - _ -> - virtuerl_ipam:assign_next(NetworkID, DomainID) - end, + + Default = maps:from_keys([ipv4_addr, ipv6_addr], undefined), + Conf0 = maps:merge(Default, Conf), + Conf1 = maps:intersect(Default, Conf0), + Conf2 = maps:to_list(Conf1), + + KeyToTag = fun(Key) -> case Key of ipv4_addr -> ipv4; ipv6_addr -> ipv6 end end, + + Addresses = [ + case Addr of + undefined -> + Tag = KeyToTag(Key), + {ok, _, Ip} = virtuerl_ipam:assign_next(NetworkID, Tag, DomainID), + {Tag, Ip}; + Addr -> + Addr1 = virtuerl_net:parse_ip(Addr), + {ok, _} = virtuerl_ipam:ipam_put_ip(NetworkID, Addr1, DomainID), + {KeyToTag(Key), Addr1} + end + || {Key, Addr} <- Conf2 + ], + #{ipv4 := Ipv4Addr, ipv6 := Ipv6Addr} = maps:from_list(Addresses), + + {ok, #{cidrs := Cidrs}} = virtuerl_ipam:ipam_get_net(NetworkID), Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), - dets:insert(Table, {DomainID, Domain#domain{network_addr =Network, ipv4_addr=IP, tap_name = TapName}}), + dets:insert(Table, {DomainID, Domain#domain{network_addrs =Cidrs, ipv4_addr=Ipv4Addr, ipv6_addr = Ipv6Addr, tap_name = TapName}}), dets:sync(Table), ok = gen_server:call(virtuerl_net, {net_update}), @@ -106,7 +122,7 @@ handle_call({domain_create, Conf}, _From, State) -> worker, [] }), - {reply, {ok, #{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => IP}}, State}; + {reply, {ok, #{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => Ipv4Addr, ipv6_addr => Ipv6Addr}}, State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index aca88e2..a1c6a95 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -73,7 +73,7 @@ update_net(Table) -> [io:format("~p~n", [Domain]) || Domain <- Domains], reload_net(Table). --record(domain, {id, network_id, network_addr, ipv4_addr, tap_name}). +-record(domain, {id, network_id, network_addrs, ipv4_addr, ipv6_addr, tap_name}). handle_interface(If, Table) -> %% 1. Delete all devices without an address set @@ -82,24 +82,27 @@ handle_interface(If, Table) -> [] -> os:cmd(io_lib:format("ip addr del ~p", [maps:get(<<"ifname">>, If)])) end. -get_cidr(If) -> +get_cidrs(If) -> Addrs = maps:get(<<"addr_info">>, If, []), Ifname = maps:get(<<"ifname">>, If), case Addrs of [] -> {unset, Ifname}; - [Something] -> {{parse_ip(maps:get(<<"local">>, Something)), maps:get(<<"prefixlen">>, Something)}, Ifname} + AddrInfos when is_list(AddrInfos) -> + Cidrs = [ iolist_to_binary([Ip, "/", integer_to_binary(Prefixlen)]) + || #{<<"local">> := Ip, <<"prefixlen">> := Prefixlen} <- AddrInfos], + {lists:sort(Cidrs), Ifname} end. reload_net(Table) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), io:format("~p~n", [JSON]), - Matched = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), + Matched = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), %% lists:foreach(fun(L) -> handle_interface(L, Table) end, Matched), io:format("Actual: ~p~n", [Matched]), Domains = dets:match_object(Table, '_'), - TargetAddrs = sets:from_list([{bridge_addr(Addr), Prefixlen} || {_, #domain{network_addr = {Addr, Prefixlen}}} <- Domains]), + TargetAddrs = sets:from_list([lists:sort(Cidrs) || {_, #domain{network_addrs = Cidrs}} <- Domains]), io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), sync_networks(Matched, TargetAddrs), sync_taps(Domains), @@ -144,8 +147,8 @@ build_routes([{Addr, Bridge}|L]) -> update_bird_conf(Domains) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), - Bridges = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), - AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #domain{network_addr = {NetAddr, Prefixlen}, ipv4_addr = Addr}} <- Domains]), + Bridges = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), + AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #domain{network_addrs = {NetAddr, Prefixlen}, ipv4_addr = Addr}} <- Domains]), AddrToBridgeMap = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, AddrMap), io:format("DOMAINS: ~p~n", [Domains]), @@ -172,9 +175,10 @@ sync_networks(ActualAddrs, TargetAddrs) -> add_bridges([], _) -> ok; -add_bridges([{Addr,Prefixlen}|T], Ifnames) -> +add_bridges([Cidrs|T], Ifnames) -> Ifname = generate_unique_bridge_name(Ifnames), - Cmd = io_lib:format("ip link add name ~s type bridge~nip addr add ~s/~B dev ~s~n", [Ifname, format_ip(Addr), Prefixlen, Ifname]), + AddrAddCmd = [io_lib:format("ip addr add ~s dev ~s~n", [Cidr, Ifname]) || Cidr <- Cidrs], + Cmd = lists:flatten([io_lib:format("ip link add name ~s type bridge~n", [Ifname]), AddrAddCmd]), io:format(Cmd), os:cmd(Cmd), add_bridges(T, Ifnames), @@ -194,7 +198,7 @@ generate_unique_bridge_name(Ifnames) -> sync_taps(Domains) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), - Bridges = maps:from_list([get_cidr(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), + Bridges = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), OutputTaps = os:cmd("ip -j link"), {ok, JSONTaps} = thoas:decode(OutputTaps), @@ -202,7 +206,7 @@ sync_taps(Domains) -> TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), TapsTarget = sets:from_list([TapName || {_, #domain{tap_name = TapName}} <- Domains]), io:format("Taps to add: ~p~n", [sets:to_list(TapsTarget)]), - TapsMap = maps:from_list([{Tap, {bridge_addr(Addr), Prefixlen}} || {_, #domain{network_addr = {Addr, Prefixlen}, tap_name = Tap}} <- Domains]), + TapsMap = maps:from_list([{Tap, {bridge_addr(Addr), Prefixlen}} || {_, #domain{network_addrs = {Addr, Prefixlen}, tap_name = Tap}} <- Domains]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), lists:foreach(fun (E) -> From 17953c701bb59be15cbd9f418e3e61c7858ccdbf Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 10 Sep 2023 22:29:51 +0200 Subject: [PATCH 22/51] virtuerl: make compatible with OTP 24 --- virtuerl/src/virtuerl_ipam.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 163dc8a..54aa24b 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -115,7 +115,8 @@ handle_call(net_list, _From, StoreId) -> {ok, Map} -> ToMapKey = fun(Tag) -> case Tag of ipv4 -> cidr4; ipv6 -> cidr6 end end, Res0 = [{NetworkId, ToMapKey(Tag), #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId, Tag], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)], - Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), + Res1 = lists:foldl(fun({NetworkId, Tag, Def}, MapAcc) -> maps:update_with(NetworkId, fun(L) -> [{Tag, Def}|L] end, [{Tag, Def}], MapAcc) end, #{}, Res0), +%% Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), Res = maps:map(fun(_, V) -> maps:from_list(V) end, Res1), {reply, {ok, Res}, StoreId}; Res -> {reply, Res, StoreId} @@ -125,7 +126,8 @@ handle_call({net_get, NetworkId}, _From, StoreId) -> {ok, Map} -> ToMapKey = fun(Tag) -> case Tag of ipv4 -> cidr4; ipv6 -> cidr6 end end, Res0 = [{NetworkId, ToMapKey(Tag), #{address => virtuerl_net:format_ip_bitstring(Address), prefixlen => PrefixLen}} || {[network, NetworkId, Tag], #network{address = Address, prefixlen = PrefixLen}} <- maps:to_list(Map)], - Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), + Res1 = lists:foldl(fun({NetworkId, Tag, Def}, MapAcc) -> maps:update_with(NetworkId, fun(L) -> [{Tag, Def}|L] end, [{Tag, Def}], MapAcc) end, #{}, Res0), +%% Res1 = maps:groups_from_list(fun({NetworkId, _, _}) -> NetworkId end, fun({_, Tag, Def}) -> {Tag, Def} end, Res0), #{NetworkId := Res} = maps:map(fun(_, V) -> maps:from_list(V) end, Res1), {reply, {ok, Res}, StoreId}; Res -> {reply, Res, StoreId} From 95539654f988bafc77969c3975881e46c7ef5b68 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 10 Sep 2023 23:34:21 +0200 Subject: [PATCH 23/51] virtuerl: fix single-stack network handling --- virtuerl/src/virtuerl_mgt.erl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 4e75800..1595c0c 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -84,7 +84,16 @@ handle_call({domain_create, Conf}, _From, State) -> dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), - Default = maps:from_keys([ipv4_addr, ipv6_addr], undefined), + {ok, #{cidrs := Cidrs}} = virtuerl_ipam:ipam_get_net(NetworkID), + Keys = lists:map(fun(Cidr) -> + {Ip, _} = virtuerl_net:parse_cidr(Cidr), + case bit_size(Ip) of + 32 -> ipv4_addr; + 128 -> ipv6_addr + end + end, Cidrs), + + Default = maps:from_keys(Keys, undefined), Conf0 = maps:merge(Default, Conf), Conf1 = maps:intersect(Default, Conf0), Conf2 = maps:to_list(Conf1), @@ -104,9 +113,10 @@ handle_call({domain_create, Conf}, _From, State) -> end || {Key, Addr} <- Conf2 ], - #{ipv4 := Ipv4Addr, ipv6 := Ipv6Addr} = maps:from_list(Addresses), + AddressesMap = maps:from_list(Addresses), + Ipv4Addr = maps:get(ipv4, AddressesMap, undefined), + Ipv6Addr = maps:get(ipv6, AddressesMap, undefined), - {ok, #{cidrs := Cidrs}} = virtuerl_ipam:ipam_get_net(NetworkID), Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), From 59a984c90066d7bcb9b872ad063fda9359703ed5 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 17 Sep 2023 00:32:36 +0200 Subject: [PATCH 24/51] virtuerl: add test suite --- virtuerl/.idea/compiler.xml | 6 ----- virtuerl/src/virtuerl_api.erl | 22 ++++++++------- virtuerl/src/virtuerl_mgt.erl | 10 +++---- virtuerl/test/virtuerl_SUITE.erl | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 21 deletions(-) delete mode 100644 virtuerl/.idea/compiler.xml create mode 100644 virtuerl/test/virtuerl_SUITE.erl diff --git a/virtuerl/.idea/compiler.xml b/virtuerl/.idea/compiler.xml deleted file mode 100644 index bfeea2e..0000000 --- a/virtuerl/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - true - - \ No newline at end of file diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index ca6b52e..8d1c25a 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -43,7 +43,7 @@ urls() -> {"^/networks/?$", networks, ['GET', 'POST']}, {"^/networks/(?[^/]+)/?$", network, ['GET', 'PUT', 'DELETE']}, {"^/domains/?$", domains, ['GET', 'POST']}, - {"^/domains/(?[^/]+)/?$", domain, ['GET']} + {"^/domains/(?[^/]+)/?$", domain, ['GET', 'DELETE']} ], CompiledUrls = lists:map(fun ({URL, Tag, Methods}) -> {ok, Pat} = re:compile(URL), @@ -165,14 +165,13 @@ handle(network, 'DELETE', #{id := ID}, Req) -> handle(domains, 'POST', _, Req) -> JSON = parse_json(Req), #{<<"domain">> := #{<<"network_id">> := NetworkID}} = JSON, - {ok, Resp} = case JSON of - #{<<"domain">> := #{<<"ipv4_addr">> := Ipv4Addr}} -> - virtuerl_mgt:domain_create(#{network_id => NetworkID, ipv4_addr => Ipv4Addr}); - _ -> - virtuerl_mgt:domain_create(#{network_id => NetworkID}) - end, - #{id := DomainID, tap_name := TapName, ip_addr := IP} = Resp, - RespJSON = thoas:encode(#{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => iolist_to_binary(virtuerl_net:format_ip(IP))}), + #{<<"domain">> := SubJSON} = JSON, + Addresses0 = maps:with([<<"ipv4_addr">>, <<"ipv6_addr">>], SubJSON), + DomainMap0 = maps:from_list([{binary_to_atom(K), V} || {K, V} <- maps:to_list(Addresses0)]), + DomainMap1 = DomainMap0#{network_id => NetworkID}, + {ok, Resp} = virtuerl_mgt:domain_create(DomainMap1), + #{id := DomainID} = Resp, + RespJSON = thoas:encode(Resp), mochiweb_request:respond({201, [{"Content-Type", "application/json"}, {"Location", "/domains/" ++ binary_to_list(DomainID)}], RespJSON}, Req); handle(domain, 'GET', #{id := ID}, Req) -> io:format("DOMAIN GET: ~p~n", [ID]), @@ -183,4 +182,7 @@ handle(domain, 'GET', #{id := ID}, Req) -> mochiweb_request:ok({[], thoas:encode(Dom)}, Req); notfound -> mochiweb_request:not_found(Req) - end. + end; +handle(domain, 'DELETE', #{id := ID}, Req) -> + io:format("DOMAIN DELETE: ~p~n", [ID]), + mochiweb_request:respond({204, [{"Content-Type", "application/json"}], <<"">>}, Req). diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 1595c0c..61ce019 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -105,17 +105,17 @@ handle_call({domain_create, Conf}, _From, State) -> undefined -> Tag = KeyToTag(Key), {ok, _, Ip} = virtuerl_ipam:assign_next(NetworkID, Tag, DomainID), - {Tag, Ip}; + {Key, Ip}; Addr -> Addr1 = virtuerl_net:parse_ip(Addr), {ok, _} = virtuerl_ipam:ipam_put_ip(NetworkID, Addr1, DomainID), - {KeyToTag(Key), Addr1} + {Key, Addr1} end || {Key, Addr} <- Conf2 ], AddressesMap = maps:from_list(Addresses), - Ipv4Addr = maps:get(ipv4, AddressesMap, undefined), - Ipv6Addr = maps:get(ipv6, AddressesMap, undefined), + Ipv4Addr = maps:get(ipv4_addr, AddressesMap, undefined), + Ipv6Addr = maps:get(ipv6_addr, AddressesMap, undefined), Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), @@ -132,7 +132,7 @@ handle_call({domain_create, Conf}, _From, State) -> worker, [] }), - {reply, {ok, #{id => DomainID, tap_name => iolist_to_binary(TapName), ip_addr => Ipv4Addr, ipv6_addr => Ipv6Addr}}, State}; + {reply, {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName)}, maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of diff --git a/virtuerl/test/virtuerl_SUITE.erl b/virtuerl/test/virtuerl_SUITE.erl new file mode 100644 index 0000000..86104a6 --- /dev/null +++ b/virtuerl/test/virtuerl_SUITE.erl @@ -0,0 +1,46 @@ +%%%------------------------------------------------------------------- +%%% @author ilya-stroeer +%%% @copyright (C) 2023, +%%% @doc +%%% +%%% @end +%%% Created : 11. Sep 2023 9:48 PM +%%%------------------------------------------------------------------- +-module(virtuerl_SUITE). +-author("ilya-stroeer"). + +%% API +-export([all/0, init_per_suite/1, end_per_suite/1]). +-export([test_domain/1, test_network/1]). + +all() -> [test_network,test_domain]. + +init_per_suite(Config) -> + {ok, _} = application:ensure_all_started(virtuerl), + Config. + +end_per_suite(_Config) -> + ok. + +test_network(_Config) -> + NetJson = thoas:encode(#{"network" => #{"cidr4" => "192.168.111.0/24", "cidr6" => "2001:db8::/80"}}), + {ok, {{_, 201, _}, Headers, _}} = httpc:request(post, {"http://localhost:8080/networks", [], "application/json", NetJson}, [], []), + Loc = proplists:get_value("location", Headers), + NetUri = uri_string:resolve(Loc, "http://localhost:8080"), + {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {NetUri, []}, [], []). + +test_domain(_Config) -> + NetJson = thoas:encode(#{"network" => #{"cidr4" => "192.168.111.0/24", "cidr6" => "2001:db8::/80"}}), + {ok, {{_, 201, _}, NetHeaders, NetBody}} = httpc:request(post, {"http://localhost:8080/networks", [], "application/json", NetJson}, [], []), + NetLoc = proplists:get_value("location", NetHeaders), + NetUri = uri_string:resolve(NetLoc, "http://localhost:8080"), + {ok, #{<<"id">> := NetId}} = thoas:decode(NetBody), + + DomainJson = thoas:encode(#{"domain" => #{"network_id" => NetId, "ipv4_addr" => "192.168.111.39"}}), + {ok, {{_, 201, _}, DomainHeaders, DomainBody}} = httpc:request(post, {"http://localhost:8080/domains", [], "application/json", DomainJson}, [], []), + DomainLoc = proplists:get_value("location", DomainHeaders), + DomainUri = uri_string:resolve(DomainLoc, "http://localhost:8080"), + {ok, #{<<"ipv4_addr">> := <<"192.168.111.39">>, <<"ipv6_addr">> := <<"2001:db8::8">>}} = thoas:decode(DomainBody), + + {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {DomainUri, []}, [], []), + {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {NetUri, []}, [], []). From 7c398aa2c3791f28a512aa68aaa924addd4c811a Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 17 Sep 2023 00:45:02 +0200 Subject: [PATCH 25/51] minivirt: fix ipv6 virtuerl handling --- minivirt/daemon.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 4dd47f6..65d761a 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -448,7 +448,8 @@ def CreateDomain(self, request, context): dom_id = virtuerl_dom["id"] tap_name = virtuerl_dom["tap_name"] ip_addr = virtuerl_dom["ipv4_addr"] - ip6_addr = virtuerl_dom["ipv6_addr"] + if ipv6_address: + ip6_addr = virtuerl_dom["ipv6_addr"] except HTTPError as e: raise e From 00c621e445115a9db22e275bcc703447e74da3e6 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 17 Sep 2023 09:13:09 +0200 Subject: [PATCH 26/51] minivirt: fix virtuerl network handling --- minivirt/daemon.py | 7 +++++-- virtuerl/test/virtuerl_SUITE.erl | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 65d761a..14845aa 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -478,10 +478,13 @@ def CreateDomain(self, request, context): vres = requests.get(f"http://localhost:8080/networks/{domreq.network}") vres.raise_for_status() vresj = vres.json() - net = ipaddress.ip_network(vresj["cidr4"], strict=False) + cidrs = [ipaddress.ip_network(cidr, strict=False) for cidr in vresj["cidrs"]] + cidr4 = [cidr for cidr in cidrs if isinstance(cidr, ipaddress.IPv4Network)] + cidr6 = [cidr for cidr in cidrs if isinstance(cidr, ipaddress.IPv6Network)] + net = cidr4[0] gateway = net[1] if ipv6_address: - net6 = ipaddress.ip_network(vresj["cidr6"], strict=False) + net6 = cidr6[0] gateway6 = net6[1] is_virtuerl_net = True diff --git a/virtuerl/test/virtuerl_SUITE.erl b/virtuerl/test/virtuerl_SUITE.erl index 86104a6..8b01f2e 100644 --- a/virtuerl/test/virtuerl_SUITE.erl +++ b/virtuerl/test/virtuerl_SUITE.erl @@ -27,6 +27,10 @@ test_network(_Config) -> {ok, {{_, 201, _}, Headers, _}} = httpc:request(post, {"http://localhost:8080/networks", [], "application/json", NetJson}, [], []), Loc = proplists:get_value("location", Headers), NetUri = uri_string:resolve(Loc, "http://localhost:8080"), + + {ok, {{_, 200, _}, _, NetBody}} = httpc:request(get, {NetUri, []}, [], []), + {ok, #{<<"cidrs">> := [<<"192.168.111.0/24">>, <<"2001:db8::/80">>]}} = thoas:decode(NetBody), + {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {NetUri, []}, [], []). test_domain(_Config) -> From 3f5d80217cdf5d133608938814c073b4f5745532 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 17 Sep 2023 10:56:36 +0200 Subject: [PATCH 27/51] virtuerl: fix net/tap sync --- virtuerl/src/virtuerl_net.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index a1c6a95..cb87b22 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -102,7 +102,7 @@ reload_net(Table) -> io:format("Actual: ~p~n", [Matched]), Domains = dets:match_object(Table, '_'), - TargetAddrs = sets:from_list([lists:sort(Cidrs) || {_, #domain{network_addrs = Cidrs}} <- Domains]), + TargetAddrs = sets:from_list([lists:sort(network_cidrs_to_bride_cidrs(Cidrs)) || {_, #domain{network_addrs = Cidrs}} <- Domains]), io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), sync_networks(Matched, TargetAddrs), sync_taps(Domains), @@ -110,6 +110,12 @@ reload_net(Table) -> update_bird_conf(Domains), ok. +network_cidrs_to_bride_cidrs(Cidrs) -> + lists:map(fun(Cidr) -> + {Addr, Prefixlen} = parse_cidr(Cidr), + iolist_to_binary(io_lib:format("~s/~B", [format_ip(bridge_addr(Addr)), Prefixlen])) + end, Cidrs). + bridge_addr(<>) -> BitSize = bit_size(Addr), <> = Addr, @@ -206,7 +212,8 @@ sync_taps(Domains) -> TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), TapsTarget = sets:from_list([TapName || {_, #domain{tap_name = TapName}} <- Domains]), io:format("Taps to add: ~p~n", [sets:to_list(TapsTarget)]), - TapsMap = maps:from_list([{Tap, {bridge_addr(Addr), Prefixlen}} || {_, #domain{network_addrs = {Addr, Prefixlen}, tap_name = Tap}} <- Domains]), + TapsMap = maps:from_list([{Tap, network_cidrs_to_bride_cidrs(Cidrs)} || {_, #domain{network_addrs = Cidrs, tap_name = Tap}} <- Domains]), + io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), lists:foreach(fun (E) -> From be84affae59b989ddd277461df19eabc3dd1911a Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 17 Sep 2023 15:07:53 +0200 Subject: [PATCH 28/51] virtuerl: set bridges/taps up --- virtuerl/src/virtuerl_api.erl | 8 +++++++- virtuerl/src/virtuerl_mgt.erl | 12 ++++++++++-- virtuerl/src/virtuerl_net.erl | 6 +++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 8d1c25a..183511b 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -185,4 +185,10 @@ handle(domain, 'GET', #{id := ID}, Req) -> end; handle(domain, 'DELETE', #{id := ID}, Req) -> io:format("DOMAIN DELETE: ~p~n", [ID]), - mochiweb_request:respond({204, [{"Content-Type", "application/json"}], <<"">>}, Req). + Resp = virtuerl_mgt:domain_delete(#{id => list_to_binary(ID)}), + case Resp of + ok -> + mochiweb_request:respond({204, [{"Content-Type", "application/json"}], <<"">>}, Req); + _ -> + mochiweb_request:respond({500, [{"Content-Type", "text/plain"}], "Error"}, Req) + end. diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 61ce019..7589c97 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -11,7 +11,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, handle_continue/2]). --export([create_vm/0, domain_create/1, domain_get/1]). +-export([create_vm/0, domain_create/1, domain_get/1, domain_delete/1]). -define(SERVER, ?MODULE). @@ -141,7 +141,15 @@ handle_call({domain_get, #{id := DomainID}}, _From, State) -> {ok, DomRet}; [] -> notfound end, - {reply, Reply, State}. + {reply, Reply, State}; +handle_call({domain_delete, #{id := DomainID}}, _From, State) -> + {Table} = State, + Res = dets:delete(Table, DomainID), + dets:sync(Table), + ok = supervisor:terminate_child(virtuerl_sup, DomainID), + ok = supervisor:delete_child(virtuerl_sup, DomainID), + ok = gen_server:call(virtuerl_net, {net_update}), + {reply, Res, State}. handle_cast(_Request, State) -> {noreply, State}. diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index cb87b22..08787dd 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -89,7 +89,7 @@ get_cidrs(If) -> [] -> {unset, Ifname}; AddrInfos when is_list(AddrInfos) -> Cidrs = [ iolist_to_binary([Ip, "/", integer_to_binary(Prefixlen)]) - || #{<<"local">> := Ip, <<"prefixlen">> := Prefixlen} <- AddrInfos], + || #{<<"local">> := Ip, <<"prefixlen">> := Prefixlen, <<"scope">> := <<"global">>} <- AddrInfos], {lists:sort(Cidrs), Ifname} end. @@ -184,7 +184,7 @@ add_bridges([], _) -> add_bridges([Cidrs|T], Ifnames) -> Ifname = generate_unique_bridge_name(Ifnames), AddrAddCmd = [io_lib:format("ip addr add ~s dev ~s~n", [Cidr, Ifname]) || Cidr <- Cidrs], - Cmd = lists:flatten([io_lib:format("ip link add name ~s type bridge~n", [Ifname]), AddrAddCmd]), + Cmd = lists:flatten([io_lib:format("ip link add name ~s type bridge~nip link set ~s up~n", [Ifname, Ifname]), AddrAddCmd]), io:format(Cmd), os:cmd(Cmd), add_bridges(T, Ifnames), @@ -233,7 +233,7 @@ end, sets:to_list(TapsToDelete)), add_taps(M) when is_map(M) -> add_taps(maps:to_list(M)); add_taps([]) -> ok; add_taps([{Tap, Bridge}|T]) -> - Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s master ~s~n", [Tap, Tap, Bridge]), + Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s master ~s~nip link set ~s up~n", [Tap, Tap, Bridge, Tap]), io:format(Cmd), os:cmd(Cmd), add_taps(T). From 883a90349cbfa03e637597feca693289c5e0a7e8 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Tue, 19 Sep 2023 23:04:18 +0200 Subject: [PATCH 29/51] virtuerl: add mac addr handling --- minivirt/daemon.py | 11 ++++++++--- virtuerl/src/virtuerl_mgt.erl | 13 ++++++++----- virtuerl/src/virtuerl_net.erl | 12 +++++++----- virtuerl/test/virtuerl_SUITE.erl | 7 ++++++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index 14845aa..cbb89e6 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -1,5 +1,6 @@ import ipaddress import os +import re import string import threading import uuid @@ -441,6 +442,7 @@ def CreateDomain(self, request, context): if ipv6_address: req_net["domain"]["ipv6_addr"] = ipv6_address + mac = None try: res = requests.post("http://localhost:8080/domains", json=req_net) res.raise_for_status() @@ -448,6 +450,8 @@ def CreateDomain(self, request, context): dom_id = virtuerl_dom["id"] tap_name = virtuerl_dom["tap_name"] ip_addr = virtuerl_dom["ipv4_addr"] + mac = virtuerl_dom["mac_addr"] + mac = ":".join(re.findall("..", mac.lower())) if ipv6_address: ip6_addr = virtuerl_dom["ipv6_addr"] except HTTPError as e: @@ -521,9 +525,10 @@ def CreateDomain(self, request, context): ip = ipaddress.ip_address(private_ip) ip6 = ipaddress.ip_address(ipv6_address) if ipv6_address else None - mac = "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format( - 0x52, 0x54, 0x00, ip.packed[-3], ip.packed[-2], ip.packed[-1] - ) + if mac is None: + mac = "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format( + 0x52, 0x54, 0x00, ip.packed[-3], ip.packed[-2], ip.packed[-1] + ) if is_virtuerl_net: netxml = f""" diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 7589c97..c4447b8 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -37,7 +37,7 @@ domains_list(Conf) -> %%% Spawning and gen_server implementation %%%=================================================================== --record(domain, {id, network_id, network_addrs, ipv4_addr, ipv6_addr, tap_name}). +-record(domain, {id, network_id, network_addrs, mac_addr, ipv4_addr, ipv6_addr, tap_name}). start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). @@ -120,7 +120,10 @@ handle_call({domain_create, Conf}, _From, State) -> Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), - dets:insert(Table, {DomainID, Domain#domain{network_addrs =Cidrs, ipv4_addr=Ipv4Addr, ipv6_addr = Ipv6Addr, tap_name = TapName}}), + <> = <<(rand:uniform(16#ffffffffffff)):48>>, + MacAddr = <>, + + dets:insert(Table, {DomainID, Domain#domain{network_addrs =Cidrs, mac_addr=MacAddr, ipv4_addr=Ipv4Addr, ipv6_addr = Ipv6Addr, tap_name = TapName}}), dets:sync(Table), ok = gen_server:call(virtuerl_net, {net_update}), @@ -132,12 +135,12 @@ handle_call({domain_create, Conf}, _From, State) -> worker, [] }), - {reply, {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName)}, maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, State}; + {reply, {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName), mac_addr => binary:encode_hex(MacAddr)}, maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of - [{_, #domain{network_id = NetworkID, ipv4_addr=IP, tap_name = TapName}}] -> - DomRet = #{network_id => NetworkID, ipv4_addr => virtuerl_net:format_ip_bitstring(IP), tap_name => iolist_to_binary(TapName)}, + [{_, #domain{network_id = NetworkID, mac_addr = MacAddr, ipv4_addr=IP, tap_name = TapName}}] -> + DomRet = #{network_id => NetworkID, mac_addr => binary:encode_hex(MacAddr), ipv4_addr => virtuerl_net:format_ip_bitstring(IP), tap_name => iolist_to_binary(TapName)}, {ok, DomRet}; [] -> notfound end, diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 08787dd..8911b16 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -73,7 +73,7 @@ update_net(Table) -> [io:format("~p~n", [Domain]) || Domain <- Domains], reload_net(Table). --record(domain, {id, network_id, network_addrs, ipv4_addr, ipv6_addr, tap_name}). +-record(domain, {id, network_id, network_addrs, mac_addr, ipv4_addr, ipv6_addr, tap_name}). handle_interface(If, Table) -> %% 1. Delete all devices without an address set @@ -212,7 +212,7 @@ sync_taps(Domains) -> TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), TapsTarget = sets:from_list([TapName || {_, #domain{tap_name = TapName}} <- Domains]), io:format("Taps to add: ~p~n", [sets:to_list(TapsTarget)]), - TapsMap = maps:from_list([{Tap, network_cidrs_to_bride_cidrs(Cidrs)} || {_, #domain{network_addrs = Cidrs, tap_name = Tap}} <- Domains]), + TapsMap = maps:from_list([{Tap, {MacAddr, network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #domain{network_addrs = Cidrs, tap_name = Tap, mac_addr = MacAddr}} <- Domains]), io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), @@ -224,7 +224,7 @@ end, sets:to_list(TapsToDelete)), TapsToAdd = sets:subtract(TapsTarget, TapsActual), - TapsMapsToAdd = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, maps:with(sets:to_list(TapsToAdd), TapsMap)), + TapsMapsToAdd = maps:map(fun (_, {MacAddr, Net}) -> {MacAddr, maps:get(Net, Bridges)} end, maps:with(sets:to_list(TapsToAdd), TapsMap)), add_taps(TapsMapsToAdd), ok. @@ -232,8 +232,10 @@ end, sets:to_list(TapsToDelete)), add_taps(M) when is_map(M) -> add_taps(maps:to_list(M)); add_taps([]) -> ok; -add_taps([{Tap, Bridge}|T]) -> - Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s master ~s~nip link set ~s up~n", [Tap, Tap, Bridge, Tap]), +add_taps([{Tap, {Mac, Bridge}}|T]) -> + <> = binary:encode_hex(Mac), + MacAddrString = <>, + Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s address ~s master ~s~nip link set ~s up~n", [Tap, Tap, MacAddrString, Bridge, Tap]), io:format(Cmd), os:cmd(Cmd), add_taps(T). diff --git a/virtuerl/test/virtuerl_SUITE.erl b/virtuerl/test/virtuerl_SUITE.erl index 8b01f2e..42dcace 100644 --- a/virtuerl/test/virtuerl_SUITE.erl +++ b/virtuerl/test/virtuerl_SUITE.erl @@ -44,7 +44,12 @@ test_domain(_Config) -> {ok, {{_, 201, _}, DomainHeaders, DomainBody}} = httpc:request(post, {"http://localhost:8080/domains", [], "application/json", DomainJson}, [], []), DomainLoc = proplists:get_value("location", DomainHeaders), DomainUri = uri_string:resolve(DomainLoc, "http://localhost:8080"), - {ok, #{<<"ipv4_addr">> := <<"192.168.111.39">>, <<"ipv6_addr">> := <<"2001:db8::8">>}} = thoas:decode(DomainBody), + {ok, #{<<"mac_addr">> := MacAddr, <<"ipv4_addr">> := <<"192.168.111.39">>, <<"ipv6_addr">> := <<"2001:db8::8">>}} = thoas:decode(DomainBody), + <<_:6, Laa:2, _/binary>> = binary:decode_hex(MacAddr), + 2 = Laa, + +%% {ok, {{_, 200, _}, _, DomainBody1}} = httpc:request(DomainUri), +%% {ok, #{<<"mac_addr">> := MacAddr, <<"ipv4_addr">> := <<"192.168.111.39">>, <<"ipv6_addr">> := <<"2001:db8::8">>}} = thoas:decode(DomainBody1), {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {DomainUri, []}, [], []), {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {NetUri, []}, [], []). From 555a6224fd73f231e8471d4d2e1a966a4c1067ca Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Thu, 21 Sep 2023 21:31:10 +0200 Subject: [PATCH 30/51] virtuerl: change port --- minivirt/daemon.py | 12 ++++++------ virtuerl/src/virtuerl_api.erl | 2 +- virtuerl/test/virtuerl_SUITE.erl | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/minivirt/daemon.py b/minivirt/daemon.py index cbb89e6..696fcc1 100644 --- a/minivirt/daemon.py +++ b/minivirt/daemon.py @@ -349,7 +349,7 @@ def CreateNetwork(self, request, context): if network.cidr6: net_json["cidr6"] = network.cidr6 res = requests.post( - "http://localhost:8080/networks", + "http://localhost:8081/networks", json={"network": net_json}, ) res.raise_for_status() @@ -376,7 +376,7 @@ def DeleteNetwork(self, request, context): except: pass - requests.delete(f"http://localhost:8080/networks/{request.uuid}") + requests.delete(f"http://localhost:8081/networks/{request.uuid}") return empty_pb2.Empty() @@ -400,7 +400,7 @@ def _get_domain(self, uuid): net = self.conn.networkLookupByName(domain_dict["network"]) domain_dict["network"] = net.UUIDString() except: - res = requests.get(f"http://localhost:8080/domains/{uuid}") + res = requests.get(f"http://localhost:8081/domains/{uuid}") resj = res.json() domain_dict["network"] = resj["network_id"] state, _ = domain_lv.state() @@ -444,7 +444,7 @@ def CreateDomain(self, request, context): mac = None try: - res = requests.post("http://localhost:8080/domains", json=req_net) + res = requests.post("http://localhost:8081/domains", json=req_net) res.raise_for_status() virtuerl_dom = res.json() dom_id = virtuerl_dom["id"] @@ -479,7 +479,7 @@ def CreateDomain(self, request, context): raise e private_ip = ip_addr - vres = requests.get(f"http://localhost:8080/networks/{domreq.network}") + vres = requests.get(f"http://localhost:8081/networks/{domreq.network}") vres.raise_for_status() vresj = vres.json() cidrs = [ipaddress.ip_network(cidr, strict=False) for cidr in vresj["cidrs"]] @@ -682,7 +682,7 @@ def DeleteDomain(self, request, context): vol = pool.storageVolLookupByName(f"{name}-cloud-init.img") vol.delete() - requests.delete(f"http://localhost:8080/domains/{str(request.uuid)}") + requests.delete(f"http://localhost:8081/domains/{str(request.uuid)}") return empty_pb2.Empty() diff --git a/virtuerl/src/virtuerl_api.erl b/virtuerl/src/virtuerl_api.erl index 183511b..57cba3a 100644 --- a/virtuerl/src/virtuerl_api.erl +++ b/virtuerl/src/virtuerl_api.erl @@ -23,7 +23,7 @@ start_link() -> {name, ?MODULE}, {loop, fun loop/1}, {ip, any}, - {port, 8080} + {port, 8081} ]). diff --git a/virtuerl/test/virtuerl_SUITE.erl b/virtuerl/test/virtuerl_SUITE.erl index 42dcace..420e2c4 100644 --- a/virtuerl/test/virtuerl_SUITE.erl +++ b/virtuerl/test/virtuerl_SUITE.erl @@ -24,9 +24,9 @@ end_per_suite(_Config) -> test_network(_Config) -> NetJson = thoas:encode(#{"network" => #{"cidr4" => "192.168.111.0/24", "cidr6" => "2001:db8::/80"}}), - {ok, {{_, 201, _}, Headers, _}} = httpc:request(post, {"http://localhost:8080/networks", [], "application/json", NetJson}, [], []), + {ok, {{_, 201, _}, Headers, _}} = httpc:request(post, {"http://localhost:8081/networks", [], "application/json", NetJson}, [], []), Loc = proplists:get_value("location", Headers), - NetUri = uri_string:resolve(Loc, "http://localhost:8080"), + NetUri = uri_string:resolve(Loc, "http://localhost:8081"), {ok, {{_, 200, _}, _, NetBody}} = httpc:request(get, {NetUri, []}, [], []), {ok, #{<<"cidrs">> := [<<"192.168.111.0/24">>, <<"2001:db8::/80">>]}} = thoas:decode(NetBody), @@ -35,15 +35,15 @@ test_network(_Config) -> test_domain(_Config) -> NetJson = thoas:encode(#{"network" => #{"cidr4" => "192.168.111.0/24", "cidr6" => "2001:db8::/80"}}), - {ok, {{_, 201, _}, NetHeaders, NetBody}} = httpc:request(post, {"http://localhost:8080/networks", [], "application/json", NetJson}, [], []), + {ok, {{_, 201, _}, NetHeaders, NetBody}} = httpc:request(post, {"http://localhost:8081/networks", [], "application/json", NetJson}, [], []), NetLoc = proplists:get_value("location", NetHeaders), - NetUri = uri_string:resolve(NetLoc, "http://localhost:8080"), + NetUri = uri_string:resolve(NetLoc, "http://localhost:8081"), {ok, #{<<"id">> := NetId}} = thoas:decode(NetBody), DomainJson = thoas:encode(#{"domain" => #{"network_id" => NetId, "ipv4_addr" => "192.168.111.39"}}), - {ok, {{_, 201, _}, DomainHeaders, DomainBody}} = httpc:request(post, {"http://localhost:8080/domains", [], "application/json", DomainJson}, [], []), + {ok, {{_, 201, _}, DomainHeaders, DomainBody}} = httpc:request(post, {"http://localhost:8081/domains", [], "application/json", DomainJson}, [], []), DomainLoc = proplists:get_value("location", DomainHeaders), - DomainUri = uri_string:resolve(DomainLoc, "http://localhost:8080"), + DomainUri = uri_string:resolve(DomainLoc, "http://localhost:8081"), {ok, #{<<"mac_addr">> := MacAddr, <<"ipv4_addr">> := <<"192.168.111.39">>, <<"ipv6_addr">> := <<"2001:db8::8">>}} = thoas:decode(DomainBody), <<_:6, Laa:2, _/binary>> = binary:decode_hex(MacAddr), 2 = Laa, From 7a095a8fa12fef3bb655cdf5c3ae466344aeeb8b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 24 Sep 2023 19:30:34 +0200 Subject: [PATCH 31/51] virtuerl: init nftables handling --- virtuerl/src/virtuerl_net.erl | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 8911b16..1da580a 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -104,18 +104,66 @@ reload_net(Table) -> TargetAddrs = sets:from_list([lists:sort(network_cidrs_to_bride_cidrs(Cidrs)) || {_, #domain{network_addrs = Cidrs}} <- Domains]), io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), + update_nftables(Domains), sync_networks(Matched, TargetAddrs), sync_taps(Domains), update_bird_conf(Domains), ok. +update_nftables(Domains) -> + BridgeAddrs = lists:flatten([network_cidrs_to_bride_addrs(Cidrs) || {_, #domain{network_addrs = Cidrs}} <- Domains]), + BridgeAddrsTyped = lists:map(fun (Addr) -> + case binary:match(Addr, <<":">>) of + nomatch -> {ipv4, Addr}; + _ -> {ipv6, Addr} + end + end, BridgeAddrs), + + DnsRules = [ + case Family of + ipv4 -> + [" ip daddr ", Addr, " ", Prot, " dport 53 dnat to ", Addr, ":5354\n"]; + ipv6 -> + [" ip6 daddr ", Addr, " ", Prot, " dport 53 dnat to [", Addr, "]:5354\n"] + end + || {Family, Addr} <- BridgeAddrsTyped, Prot <- ["tcp", "udp"]], + + IoList = [ + "table inet virtuerl\ndelete table inet virtuerl\n\n", + "table inet virtuerl {\n", + " chain output {\n", + " type nat hook output priority -105; policy accept;\n", + DnsRules, + " }\n", + + " chain prerouting {\n", + " type nat hook prerouting priority dstnat - 5; policy accept;\n", + DnsRules, + " }\n", + "}\n" + ], + io:format("~s~n", [IoList]), + + Path = iolist_to_binary(["/tmp/virtuerl/", "nftables_", virtuerl_util:uuid4(), ".conf"]), + ok = filelib:ensure_dir(Path), + ok = file:write_file(Path, IoList), + + os:cmd(io_lib:format("nft -f ~s", [Path])), + file:delete(Path). + network_cidrs_to_bride_cidrs(Cidrs) -> lists:map(fun(Cidr) -> {Addr, Prefixlen} = parse_cidr(Cidr), iolist_to_binary(io_lib:format("~s/~B", [format_ip(bridge_addr(Addr)), Prefixlen])) end, Cidrs). +network_cidrs_to_bride_addrs(Cidrs) -> + lists:map(fun(Cidr) -> + {Addr, _} = parse_cidr(Cidr), + iolist_to_binary(io_lib:format("~s", [format_ip(bridge_addr(Addr))])) + end, Cidrs). + bridge_addr(<>) -> BitSize = bit_size(Addr), <> = Addr, From 23f5dfec23a8be3d92aa74751992f774a2edee2b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 5 Jan 2024 23:29:08 +0100 Subject: [PATCH 32/51] virtuerl: wip --- .github/workflows/build.yaml | 6 +- virtuerl/.idea/modules.xml | 1 + virtuerl/config/sys.config | 5 +- virtuerl/rebar.config | 8 +- virtuerl/rebar.lock | 3 + virtuerl/src/virtuerl.app.src | 6 +- virtuerl/src/virtuerl_app.erl | 2 + virtuerl/src/virtuerl_ipam.erl | 10 +- virtuerl/src/virtuerl_mgt.erl | 75 +++++++++--- virtuerl/src/virtuerl_net.erl | 25 ++-- virtuerl/src/virtuerl_qemu.erl | 211 ++++++++++++++++++++++++++------- virtuerl/src/virtuerl_qmp.erl | 97 +++++++++++++++ virtuerl/src/virtuerl_stor.erl | 48 ++++++++ virtuerl/src/virtuerl_util.erl | 13 +- 14 files changed, 424 insertions(+), 86 deletions(-) create mode 100644 virtuerl/src/virtuerl_qmp.erl create mode 100644 virtuerl/src/virtuerl_stor.erl diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a1fb53..4656183 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -39,7 +39,7 @@ jobs: - name: Setup Virtuerl working-directory: virtuerl run: | - sudo -s rebar3 compile + rebar3 release cat << EOF | sudo tee -a /etc/systemd/system/virtuerl.service [Unit] @@ -47,8 +47,8 @@ jobs: After=network.target [Service] - WorkingDirectory=${PWD} - ExecStart=/bin/sh -c 'erl -pa _build/default/lib/*/ebin -config config/sys.config -s virtuerl_app -noshell -noinput' + WorkingDirectory=${PWD}/_build/default/rel/virtuerl/ + ExecStart=bin/virtuerl foreground Restart=always [Install] diff --git a/virtuerl/.idea/modules.xml b/virtuerl/.idea/modules.xml index 540417d..d627cff 100644 --- a/virtuerl/.idea/modules.xml +++ b/virtuerl/.idea/modules.xml @@ -5,6 +5,7 @@ + diff --git a/virtuerl/config/sys.config b/virtuerl/config/sys.config index 9cd128b..c65080a 100644 --- a/virtuerl/config/sys.config +++ b/virtuerl/config/sys.config @@ -2,7 +2,7 @@ [{logger_level, all}, {logger, [{handler, default, logger_std_h, - #{ level => info, + #{ level => debug, formatter => {logger_formatter, #{single_line => false}}}} ]}]}, {grpcbox, [ @@ -11,5 +11,6 @@ {keyfile, "config/client.key"}, {cacertfile, "config/ca.crt"} ]}], #{}}]}} - ]} + ]}, + {erlexec, [{root, true}, {user, "root"}]} ]. diff --git a/virtuerl/rebar.config b/virtuerl/rebar.config index 0ec98a0..c3f9abc 100644 --- a/virtuerl/rebar.config +++ b/virtuerl/rebar.config @@ -4,7 +4,13 @@ {thoas, "1.0.0"}, {grpcbox, "0.16.0"}, {cowboy, "2.10.0"}, - {mochiweb, "3.1.2"} + {mochiweb, "3.1.2"}, + {erlexec, "~> 2.0"} +]}. + +{relx, [ + {release, {virtuerl, git}, [virtuerl, {khepri, load}, {mnesia, load}]}, + {mode, prod} ]}. {plugins, [grpcbox_plugin]}. diff --git a/virtuerl/rebar.lock b/virtuerl/rebar.lock index 21dace2..347e593 100644 --- a/virtuerl/rebar.lock +++ b/virtuerl/rebar.lock @@ -5,6 +5,7 @@ {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.10.0">>},0}, {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.12.1">>},1}, {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},1}, + {<<"erlexec">>,{pkg,<<"erlexec">>,<<"2.0.2">>},0}, {<<"gen_batch_server">>,{pkg,<<"gen_batch_server">>,<<"0.8.8">>},2}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1}, {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.16.0">>},0}, @@ -24,6 +25,7 @@ {<<"cowboy">>, <<"FF9FFEFF91DAE4AE270DD975642997AFE2A1179D94B1887863E43F681A203E26">>}, {<<"cowlib">>, <<"A9FA9A625F1D2025FE6B462CB865881329B5CAFF8F1854D1CBC9F9533F00E1E1">>}, {<<"ctx">>, <<"8FF88B70E6400C4DF90142E7F130625B82086077A45364A78D208ED3ED53C7FE">>}, + {<<"erlexec">>, <<"995E40477DE94C37EC1264CC3E52EB6273938E80C9BCC4F94110A3F1C0D9ABA3">>}, {<<"gen_batch_server">>, <<"7840A1FA63EE1EFFC83E8A91D22664847A2BA1192D30EAFFFD914ACB51578068">>}, {<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>}, {<<"grpcbox">>, <<"B83F37C62D6EECA347B77F9B1EC7E9F62231690CDFEB3A31BE07CD4002BA9C82">>}, @@ -42,6 +44,7 @@ {<<"cowboy">>, <<"3AFDCCB7183CC6F143CB14D3CF51FA00E53DB9EC80CDCD525482F5E99BC41D6B">>}, {<<"cowlib">>, <<"163B73F6367A7341B33C794C4E88E7DBFE6498AC42DCD69EF44C5BC5507C8DB0">>}, {<<"ctx">>, <<"A14ED2D1B67723DBEBBE423B28D7615EB0BDCBA6FF28F2D1F1B0A7E1D4AA5FC2">>}, + {<<"erlexec">>, <<"CC829A7C6C23D399832DA2E998EA5EBC552232A6FE3EB1EDB400178EC8287DCB">>}, {<<"gen_batch_server">>, <<"C3E6A1A2A0FB62AEE631A98CFA0FD8903E9562422CBF72043953E2FB1D203017">>}, {<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>}, {<<"grpcbox">>, <<"294DF743AE20A7E030889F00644001370A4F7CE0121F3BBDAF13CF3169C62913">>}, diff --git a/virtuerl/src/virtuerl.app.src b/virtuerl/src/virtuerl.app.src index 556bc45..8d29911 100644 --- a/virtuerl/src/virtuerl.app.src +++ b/virtuerl/src/virtuerl.app.src @@ -6,7 +6,11 @@ {applications, [kernel, stdlib, - cowboy + inets, + mochiweb, + cowboy, + thoas, + erlexec ]}, {env,[]}, {modules, []}, diff --git a/virtuerl/src/virtuerl_app.erl b/virtuerl/src/virtuerl_app.erl index db57f77..6a3d662 100644 --- a/virtuerl/src/virtuerl_app.erl +++ b/virtuerl/src/virtuerl_app.erl @@ -19,10 +19,12 @@ start(_StartType, _StartArgs) -> %% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), %% io:format("RESULT: ~p~n", [Res]), %% {ok, _} = Res, +%% exec:debug(4), virtuerl_sup:start_link(). start() -> application:ensure_all_started(virtuerl). +%% exec:debug(4). stop(_State) -> ok. diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 54aa24b..a839199 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -96,19 +96,13 @@ start_link() -> init([]) -> io:format("starting IPAM service~n"), - {ok, StoreId} = khepri:start(), + {ok, StoreId} = khepri:start(filename:join(virtuerl_mgt:home_path(), "khepri")), init([StoreId]); init([StoreId]) -> {ok, StoreId}. terminate(_Reason, StoreId) -> - DefaultStoreId = khepri_cluster:get_default_store_id(), - case StoreId of - DefaultStoreId -> - khepri:stop(StoreId); - _ -> - ok - end. + khepri:stop(StoreId). handle_call(net_list, _From, StoreId) -> case khepri:get_many(StoreId, [network, ?KHEPRI_WILDCARD_STAR, ?KHEPRI_WILDCARD_STAR]) of diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index c4447b8..8aac529 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -11,9 +11,11 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, handle_continue/2]). --export([create_vm/0, domain_create/1, domain_get/1, domain_delete/1]). +-export([create_vm/0, domain_create/1, domain_get/1, domain_delete/1, domain_stop/1, domain_start/1]). +-export([home_path/0]). -define(SERVER, ?MODULE). +-define(APPLICATION, virtuerl). create_vm() -> gen_server:call(?SERVER, {domain_create, {default}}). @@ -31,35 +33,63 @@ domain_get(Conf) -> domains_list(Conf) -> gen_server:call(?SERVER, {domains_list, Conf}). +domain_stop(Id) -> + gen_server:call(?SERVER, {domain_update, #{id => Id, state => stopped}}). + +domain_start(Id) -> + gen_server:call(?SERVER, {domain_update, #{id => Id, state => running}}). %%%=================================================================== %%% Spawning and gen_server implementation %%%=================================================================== --record(domain, {id, network_id, network_addrs, mac_addr, ipv4_addr, ipv6_addr, tap_name}). +home_path() -> + application:get_env(?APPLICATION, home, "var"). start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). init([]) -> - {ok, Table} = dets:open_file(vms, []), + {ok, Table} = dets:open_file(domains, [{file, filename:join(home_path(), "domains.dets")}]), %% virtuerl_ipam:ipam_put_net({default, <<192:8, 168:8, 10:8, 0:8>>, 28}), %% application:ensure_all_started(grpcbox), - {ok, {Table}, {continue, sync_domains}}. + {ok, {Table}, {continue, setup_base}}. %% {ok, {Table}}. -handle_continue(sync_domains, State) -> - {Table} = State, - TargetDomains = sets:from_list([Id || {Id, _} <- dets:match_object(Table, '_')]), +handle_continue(setup_base, State) -> + ok = filelib:ensure_path(filename:join(home_path(), "domains")), + + BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), + case filelib:is_regular(BaseImagePath) of + true -> ok; + false -> + TempImagePath = "/tmp/virtuerl/debian-12-genericcloud-amd64-20230910-1499.qcow2", + ok = filelib:ensure_dir(TempImagePath), + httpc:request(get, "https://cloud.debian.org/images/cloud/bookworm/20230910-1499/debian-12-genericcloud-arm64-20230910-1499.qcow2", [], + [{stream, TempImagePath}]), + file:rename(TempImagePath, BaseImagePath) + end, + + {noreply, State, {continue, sync_domains}}; + + +handle_continue(sync_domains, {Table} = State) -> + TargetDomains = sets:from_list([Id || {Id, Domain} <- dets:match_object(Table, '_'), + case Domain of + #{state := stopped} -> false; + _ -> true + end]), RunningDomains = sets:from_list([Id || {Id, _, _, _} <- supervisor:which_children(virtuerl_sup), is_binary(Id)]), ToDelete = sets:subtract(RunningDomains, TargetDomains), ToAdd = sets:subtract(TargetDomains, RunningDomains), + [supervisor:terminate_child(virtuerl_sup, Id) || Id <- sets:to_list(ToDelete)], [supervisor:delete_child(virtuerl_sup, Id) || Id <- sets:to_list(ToDelete)], + ok = gen_server:call(virtuerl_net, {net_update}), [ supervisor:start_child(virtuerl_sup, { Id, {virtuerl_qemu, start_link, [Id]}, - permanent, + transient, infinity, worker, [] @@ -80,7 +110,7 @@ handle_call({domain_create, Conf}, _From, State) -> {Table} = State, #{network_id := NetworkID} = Conf, DomainID = virtuerl_util:uuid4(), - Domain = #domain{id = DomainID, network_id = NetworkID}, % TODO: save ipv4 addr as well + Domain = #{id => DomainID, network_id => NetworkID}, % TODO: save ipv4 addr as well dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), @@ -104,29 +134,31 @@ handle_call({domain_create, Conf}, _From, State) -> case Addr of undefined -> Tag = KeyToTag(Key), - {ok, _, Ip} = virtuerl_ipam:assign_next(NetworkID, Tag, DomainID), - {Key, Ip}; + {ok, {NetAddr, Prefixlen}, Ip} = virtuerl_ipam:assign_next(NetworkID, Tag, DomainID), + {Key, NetAddr, Ip, Prefixlen}; Addr -> Addr1 = virtuerl_net:parse_ip(Addr), - {ok, _} = virtuerl_ipam:ipam_put_ip(NetworkID, Addr1, DomainID), - {Key, Addr1} + {ok, {NetAddr, Prefixlen}} = virtuerl_ipam:ipam_put_ip(NetworkID, Addr1, DomainID), + {Key, NetAddr, Addr1, Prefixlen} end || {Key, Addr} <- Conf2 ], - AddressesMap = maps:from_list(Addresses), + IpCidrs = [{Ip, Prefixlen} || {_, _, Ip, Prefixlen} <- Addresses], + AddressesMap = maps:from_list([{K, A} || {K, _, A, _} <- Addresses]), Ipv4Addr = maps:get(ipv4_addr, AddressesMap, undefined), Ipv6Addr = maps:get(ipv6_addr, AddressesMap, undefined), Domains = dets:match_object(Table, '_'), - TapNames = sets:from_list([Tap || #domain{tap_name=Tap} <- Domains]), + TapNames = sets:from_list([Tap || #{tap_name := Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), <> = <<(rand:uniform(16#ffffffffffff)):48>>, MacAddr = <>, - dets:insert(Table, {DomainID, Domain#domain{network_addrs =Cidrs, mac_addr=MacAddr, ipv4_addr=Ipv4Addr, ipv6_addr = Ipv6Addr, tap_name = TapName}}), + dets:insert(Table, {DomainID, Domain#{network_addrs => Cidrs, mac_addr=>MacAddr, ipv4_addr=>Ipv4Addr, ipv6_addr => Ipv6Addr, cidrs => IpCidrs, tap_name => TapName}}), dets:sync(Table), ok = gen_server:call(virtuerl_net, {net_update}), + supervisor:start_child(virtuerl_sup, { DomainID, {virtuerl_qemu, start_link, [DomainID]}, @@ -136,10 +168,19 @@ handle_call({domain_create, Conf}, _From, State) -> [] }), {reply, {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName), mac_addr => binary:encode_hex(MacAddr)}, maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, State}; +handle_call({domain_update, #{id := DomainID, state := RunState}}, _From, {Table} = State) -> + Reply = case dets:lookup(Table, DomainID) of + [{_, Domain}] -> + ok = dets:insert(Table, {DomainID, Domain#{state := RunState}}), + ok = dets:sync(Table), + ok; + [] -> notfound + end, + {reply, Reply, State, {continue, sync_domains}}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of - [{_, #domain{network_id = NetworkID, mac_addr = MacAddr, ipv4_addr=IP, tap_name = TapName}}] -> + [{_, #{network_id := NetworkID, mac_addr := MacAddr, ipv4_addr:=IP, tap_name := TapName}}] -> DomRet = #{network_id => NetworkID, mac_addr => binary:encode_hex(MacAddr), ipv4_addr => virtuerl_net:format_ip_bitstring(IP), tap_name => iolist_to_binary(TapName)}, {ok, DomRet}; [] -> notfound diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 1da580a..3a60067 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -13,7 +13,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --export([parse_cidr/1, format_ip/1, format_ip_bitstring/1, parse_ip/1]). +-export([parse_cidr/1, format_ip/1, format_ip_bitstring/1, parse_ip/1, bridge_addr/1, bridge_addr/2]). -define(SERVER, ?MODULE). @@ -26,7 +26,7 @@ start_link() -> init([]) -> ?LOG_INFO(#{what => "Started", who => virtuerl_net}), - {ok, Table} = dets:open_file(vms, []), + {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), update_net(Table), % TODO: erlexec: spawn bird -f {ok, {Table}}. @@ -73,8 +73,6 @@ update_net(Table) -> [io:format("~p~n", [Domain]) || Domain <- Domains], reload_net(Table). --record(domain, {id, network_id, network_addrs, mac_addr, ipv4_addr, ipv6_addr, tap_name}). - handle_interface(If, Table) -> %% 1. Delete all devices without an address set Addrs = maps:get(<<"addr_info">>, If, []), @@ -102,7 +100,7 @@ reload_net(Table) -> io:format("Actual: ~p~n", [Matched]), Domains = dets:match_object(Table, '_'), - TargetAddrs = sets:from_list([lists:sort(network_cidrs_to_bride_cidrs(Cidrs)) || {_, #domain{network_addrs = Cidrs}} <- Domains]), + TargetAddrs = sets:from_list([lists:sort(network_cidrs_to_bride_cidrs(Cidrs)) || {_, #{network_addrs := Cidrs}} <- Domains]), io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), update_nftables(Domains), sync_networks(Matched, TargetAddrs), @@ -112,7 +110,7 @@ reload_net(Table) -> ok. update_nftables(Domains) -> - BridgeAddrs = lists:flatten([network_cidrs_to_bride_addrs(Cidrs) || {_, #domain{network_addrs = Cidrs}} <- Domains]), + BridgeAddrs = lists:uniq(lists:flatten([network_cidrs_to_bride_addrs(Cidrs) || {_, #{network_addrs := Cidrs}} <- Domains])), BridgeAddrsTyped = lists:map(fun (Addr) -> case binary:match(Addr, <<":">>) of nomatch -> {ipv4, Addr}; @@ -168,6 +166,9 @@ bridge_addr(<>) -> BitSize = bit_size(Addr), <> = Addr, <<(AddrInt+1):BitSize>>. +bridge_addr(<>, Prefixlen) -> + <> = Addr, + <>. parse_cidr(<>) -> parse_cidr(binary_to_list(CIDR)); parse_cidr(CIDR) -> @@ -202,7 +203,7 @@ update_bird_conf(Domains) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), Bridges = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), - AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #domain{network_addrs = {NetAddr, Prefixlen}, ipv4_addr = Addr}} <- Domains]), + AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #{network_addrs := {NetAddr, Prefixlen}, ipv4_addr := Addr}} <- Domains]), AddrToBridgeMap = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, AddrMap), io:format("DOMAINS: ~p~n", [Domains]), @@ -258,9 +259,10 @@ sync_taps(Domains) -> {ok, JSONTaps} = thoas:decode(OutputTaps), io:format("TAPS: ~p~n", [JSONTaps]), TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), - TapsTarget = sets:from_list([TapName || {_, #domain{tap_name = TapName}} <- Domains]), - io:format("Taps to add: ~p~n", [sets:to_list(TapsTarget)]), - TapsMap = maps:from_list([{Tap, {MacAddr, network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #domain{network_addrs = Cidrs, tap_name = Tap, mac_addr = MacAddr}} <- Domains]), + TapsTarget = sets:from_list([iolist_to_binary(TapName) || {_, #{tap_name := TapName}} <- Domains]), % TODO: persist tap_name as binary + io:format("Taps Target: ~p~n", [sets:to_list(TapsTarget)]), + io:format("Taps Actual: ~p~n", [sets:to_list(TapsActual)]), + TapsMap = maps:from_list([{iolist_to_binary(Tap), {MacAddr, network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), @@ -281,8 +283,7 @@ end, sets:to_list(TapsToDelete)), add_taps(M) when is_map(M) -> add_taps(maps:to_list(M)); add_taps([]) -> ok; add_taps([{Tap, {Mac, Bridge}}|T]) -> - <> = binary:encode_hex(Mac), - MacAddrString = <>, + MacAddrString = virtuerl_util:mac_to_str(Mac), Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s address ~s master ~s~nip link set ~s up~n", [Tap, Tap, MacAddrString, Bridge, Tap]), io:format(Cmd), os:cmd(Cmd), diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index f7194e4..54def68 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -8,9 +8,10 @@ -behaviour(gen_server). --export([start_link/1]). --export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, - code_change/3]). +-export([start_link/1, callback_mode/0]). +-export([init/1, terminate/2]). +-export([handle_continue/2, handle_info/2]). +-export([handle_call/3, handle_cast/2]). -define(SERVER, ?MODULE). @@ -20,51 +21,179 @@ start_link(ID) -> %% gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). - Pid = spawn_link(fun() -> - io:format("QEMU: Starting VM with ID ~p~n", [ID]), - timer:sleep(20000), - io:format("QEMU: Exiting ~p~n", [ID]), - timer:sleep(500), - exit(failure) - - end), - {ok, Pid}. - -init([]) -> - {ok, Table} = dets:open_file(vms, []), - % TODO: erlexec: spawn bird -f - {ok, {Table}}. - -terminate(_Reason, {Table}) -> - dets:close(Table). +%% Pid = spawn_link(fun() -> +%% io:format("QEMU: Starting VM with ID ~p~n", [ID]), +%% timer:sleep(20000), +%% io:format("QEMU: Exiting ~p~n", [ID]), +%% timer:sleep(500), +%% exit(failure) +%% +%% end), +%% {ok, Pid}. + + gen_server:start_link(?MODULE, [ID], []). + +callback_mode() -> + handle_event_function. + +init([ID]) -> + {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), + [{DomainId, #{mac_addr:=MacAddr, tap_name := TapName} = Domain}] = dets:lookup(Table, ID), + DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId]), + ok = filelib:ensure_path(DomainHomePath), + RootVolumePath = filename:join(DomainHomePath, "root.qcow2"), + case filelib:is_regular(RootVolumePath) of + false -> + BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), + exec:run(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s", [filename:absname(BaseImagePath), RootVolumePath])); + _ -> noop + end, + process_flag(trap_exit, true), + ensure_cloud_config(Domain), + file:delete(filename:join(DomainHomePath, "qmp.sock")), + file:delete(filename:join(DomainHomePath, "serial.sock")), + Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -display none -m 512 -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -display none -qmp unix:qmp.sock,server=on,wait=off -serial unix:serial.sock,server=on,wait=off"]), + io:format("QEMU cmdline: ~s~n", [Cmd]), + {ok, Pid, OsPid} = exec:run_link(Cmd, [{cd, DomainHomePath}]), + State = #{table => Table, id => ID, domain => Domain, qemu_pid => {Pid, OsPid}, qmp_pid => undefined}, + {ok, State, {continue, setup_qmp}}. + +handle_continue(setup_qmp, #{id := ID} = State) -> + QmpSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "qmp.sock"]), + io:format("waiting for qmp.sock ~p~n", [erlang:timestamp()]), +%% {ok, _} = exec:run(iolist_to_binary(["inotifywait -e create --include 'qmp\\.sock' ", ID]), [sync]), + ok = wait_for_socket(ID), + io:format("done waiting for qmp.sock ~p~n", [erlang:timestamp()]), + {ok, QmpPid} = virtuerl_qmp:start_link(QmpSocketPath, self()), + virtuerl_qmp:exec(QmpPid, cont), + {noreply, State#{qmp_pid => QmpPid}}. -handle_call({vm_create, Conf}, _From, State) -> - {reply, ok, State}. +handle_info({qmp, Event}, #{table := Table, id := ID, domain := Domain} = State) -> + io:format("QMP: ~p~n", [Event]), + case Event of + #{<<"event">> := <<"STOP">>} -> + [{DomainId, Domain}] = dets:lookup(Table, ID), + DomainUpdated = Domain#{state => stopped}, + ok = dets:insert(Table, {DomainId, DomainUpdated}), + ok = dets:sync(Table), + {stop, normal, State#{domain => DomainUpdated}}; + _ -> {noreply, State} + end. -handle_cast({net_update}, State) -> - {Table} = State, - update_bird_conf(Table), - {noreply, State}. +shutdown_events() -> + receive + {qmp, Event} -> + io:format("shutdown QMP: ~p~n", [Event]), + shutdown_events() + after 5000 -> ok + end. -handle_info(_Info, State) -> - {noreply, State}. +exit_events() -> + receive + {'EXIT', _Pid, _Reason} -> + io:format("EXIT ~p ~p!~n", [_Pid, _Reason]), + exit_events() + after 10000 -> ok + end. -code_change(_OldVsn, State, _Extra) -> - {ok, State}. +terminate(_Reason, #{table := Table, id := ID, domain := Domain, qemu_pid := {Pid, OsPid}, qmp_pid := QmpPid}) -> + io:format("GRACEFUL SHUTDOWN: ~s (~p)~n", [ID, _Reason]), + case _Reason of + normal -> ok; + _ -> % supervisor sends "shutdown" + virtuerl_qmp:exec(QmpPid, system_powerdown), +%% shutdown_events(), + receive + {qmp, #{<<"event">> := <<"STOP">>}} -> ok + after 5000 -> timeout + end + end, +%% {ok, #{<<"return">> := #{}}} = thoas:decode(PowerdownRes), + ok = virtuerl_qmp:stop(QmpPid), + ok = exec:stop(Pid), + receive + {'EXIT', Pid, _} -> + io:format("QEMU OS process stopped!~n"), + ok; + {'EXIT', OsPid, _} -> + io:format("QEMU OS process stopped (OsPid)!~n"), + ok + after 5000 -> timeout + end, +%% exit_events(), + dets:close(Table). %%%=================================================================== %%% Internal functions %%%=================================================================== -update_bird_conf(Table) -> - % 1. write config - %% for VM in VMs: - %% append VM.IP to static routes: VM.IP via $VM.network.bridge - % 2. birdc configure - % 3. profit? - VMs = dets:match_object(Table, '_'), - [io:format("~p~n", [VM]) || VM <- VMs], - reload_bird(). - -reload_bird() -> +wait_for_socket(ID) -> + QmpSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "qmp.sock"]), + io:format("checking...~n"), + case filelib:last_modified(QmpSocketPath) of + 0 -> + timer:sleep(20), + wait_for_socket(ID); + _ -> ok + end. + +ensure_cloud_config(#{id := DomainID} = Domain) -> + case filelib:is_regular(filename:join([virtuerl_mgt:home_path(), "domains", DomainID, "cloud_config.iso"])) of + true -> ok; + false -> create_cloud_config(Domain) + end. + +create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs}) -> + NetConf = [ + "version: 2\n", + "ethernets:\n", + " primary:\n", + " match:\n", + " macaddress: \"", virtuerl_util:mac_to_str(MacAddr), "\"\n", + " set-name: ens2\n", + " dhcp4: false\n", + " dhcp6: false\n", + " addresses:\n", [[ + " - ", virtuerl_net:format_ip(IpAddr), "/", integer_to_binary(Prefixlen), "\n"] || {IpAddr, Prefixlen} <- Cidrs], + " routes:\n", [[ + " - to: default\n", + " via: ", virtuerl_net:format_ip(virtuerl_net:bridge_addr(IpAddr, Prefixlen)), "\n"] || {IpAddr, Prefixlen} <- Cidrs], + "" + ], + MetaData = [ + "instance-id: ", DomainID, "\n", + "local-hostname: ", DomainID, "\n" + ], + % openssl passwd -6 + UserData = [ + "#cloud-config\n", + "users:\n", + " - default\n", + " - name: ilya\n", + " passwd: $6$VAKAlO91OquUA1ON$4w2.omQG9OUt0KuMtCvYrJgervyK8WZrTMFUhJI2fXTsfMN5YvuxKaZbSJTXkJvq4qAiFHptt6zKg2hTMOrkH0\n", + " lock_passwd: false\n", + " shell: /bin/bash\n", + " sudo: ALL=(ALL) NOPASSWD:ALL\n", + " ssh_authorized_keys:\n", + " - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCKxHNpVg1whPegPv0KcRQTOfyVIqLwvMfVLyT9OpBPXHDudsFz9soOgMUEyWm8ZJ+pJ9fRCg66B+D5/ZRTwJCBpyNncfXCwu8xEJgEeoIubObh6t6dHWqqxX/yhHAS5GIRUSypm78qg6V+SQ6SeJXSjOCLAbZmhyWgJrlDm9M6GTPQhPAztrgsCUrzxIpZ5el5BwJXrm3I+LOmofAUqgbLQz9HuGJzPpnfABDa9WoVfI0L7oTr0qGpWwx8l71b2s8AYl7GMD/bEkZKyi9SSwEVCHA88F7dYYrZ3+fMXE/mJf+v0ece2lIDT7Te1gtqiLu/izJNmqD+b6mtnnXxVxNOtynhv3t6uLE9kBX22SBCCRqPJzETGNXvYH6fATEe88dhLh8kTppLRB5UGUd/zztxuNBSpMwFXaq8SlTKURxvF8BuFIPCz0FW8fq+TA/xZfBYsiVt59jXgl6BQyEGY4bMuMtT2nD8QXwZ5vsj52mzKGJwBwduiaX302brHYUyQkuyLII5iqmCNZ5YLlMY76a61Yg9pWMeRwQscSO2k4a18GOo+sIrQVTyUQiT3KhRRaDNrZuCPicQRgkJuiS1fKt1cWjnOlyweLxSYbpKnoS0H7vt+NrtbU1u9FPknXQPQ0pxixPpV3zgUdfOLmisFH7WGVjwNVvZAlNc5uyqm0fbw== ilya@verbit.io\n", + "" + ], + DomainBasePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), + IsoBasePath = filename:join(DomainBasePath, "iso"), + ok = filelib:ensure_path(IsoBasePath), + NetConfPath = filename:join(IsoBasePath, "network-config"), + ok = file:write_file(NetConfPath, NetConf), + MetaDataPath = filename:join(IsoBasePath, "meta-data"), + ok = file:write_file(MetaDataPath, MetaData), + UserDataPath = filename:join(IsoBasePath, "user-data"), + ok = file:write_file(UserDataPath, UserData), + IsoCmd = ["genisoimage -output ", filename:join(DomainBasePath, "cloud_config.iso"), " -volid cidata -joliet -rock ", UserDataPath, " ", MetaDataPath, " ", NetConfPath], + os:cmd(binary_to_list(iolist_to_binary(IsoCmd))), + ok = file:del_dir_r(IsoBasePath), ok. + +handle_call(Request, From, State) -> + erlang:error(not_implemented). + +handle_cast(Request, State) -> + erlang:error(not_implemented). diff --git a/virtuerl/src/virtuerl_qmp.erl b/virtuerl/src/virtuerl_qmp.erl new file mode 100644 index 0000000..c1c736b --- /dev/null +++ b/virtuerl/src/virtuerl_qmp.erl @@ -0,0 +1,97 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_qmp). + +-behaviour(gen_server). + +-export([start_link/2, handle_cast/2]). +-export([init/1, terminate/2]). +-export([handle_call/3, handle_info/2]). +-export([exec/2, stop/1]). + +-define(SERVER, ?MODULE). + +exec(Pid, Command) -> + gen_server:call(Pid, Command). + +stop(Pid) -> + gen_server:stop(Pid). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start_link(QmpSocketPath, Receiver) -> + gen_server:start_link(?MODULE, {QmpSocketPath, Receiver}, []). + +init({QmpSocketPath, Receiver}) -> + Self = self(), + Pid = spawn_link(fun () -> qmp_translator(QmpSocketPath, Self) end), + io:format("virtuerl_qmp: init~n"), + receive + {qmp, #{<<"QMP">> := #{}}} -> ok + after 1000 -> exit(qmp_not_responding) + end, + io:format("virtuerl_qmp: init after~n"), + execute(Pid, qmp_capabilities), + io:format("virtuerl_qmp: qmp caps~n"), + {ok, {Pid, Receiver}}. + +terminate(_Reason, {Pid, _}) -> + Ref = monitor(process, Pid), + exit(Pid, normal), + receive + {'DOWN', Ref, process, Pid, normal} -> ok + end, + true = demonitor(Ref), + io:format("exiting QMP server~n"). + +handle_call(Command, _From, {Pid, _} = State) -> + execute(Pid, Command), + {reply, ok, State}. + +handle_cast(Request, State) -> + erlang:error(not_implemented). + +handle_info({qmp, #{<<"event">> := _} = Event}, {_, Receiver} = State) -> + Receiver ! {qmp, Event}, + {noreply, State}. + +execute(Pid, Command) when is_pid(Pid) -> + Pid ! {qmp, Command}, + receive + {qmp, #{<<"return">> := #{}}} -> ok + end. + +%%%=================================================================== +%%% Internal functions +%%%=================================================================== + +qmp_translator(QmpSocketPath, Receiver) -> + process_flag(trap_exit, true), + io:format("starting QMP translator (~s)!~n", [QmpSocketPath]), + {ok, QmpSocket} = gen_tcp:connect({local, QmpSocketPath}, 0, [local, {active, true}]), + qmp_loop(QmpSocket, Receiver). + +qmp_loop(QmpSocket, Receiver) -> + receive + {tcp, _Socket, RawData} -> + io:format("qmp_loop/tcp/raw: ~p~n", [RawData]), + Lines = re:split(RawData, "\r?\n", [trim]), + Jsons = lists:map(fun (Line) -> {ok, Json} = thoas:decode(Line), Json end, Lines), + io:format("qmp_loop/tcp: ~p~n", [Jsons]), + [Receiver ! {qmp, Json} || Json <- Jsons], + qmp_loop(QmpSocket, Receiver); + {qmp, Command} when is_atom(Command) -> + io:format("qmp_loop/qmp: ~p~n", [Command]), + ok = gen_tcp:send(QmpSocket, thoas:encode(#{execute => Command})), + qmp_loop(QmpSocket, Receiver); + {'EXIT', _SenderID, Reason} -> + io:format("closing QMP socket (~p)!~n", [Reason]), + ok = gen_tcp:close(QmpSocket), + exit(Reason) + end. diff --git a/virtuerl/src/virtuerl_stor.erl b/virtuerl/src/virtuerl_stor.erl new file mode 100644 index 0000000..3862075 --- /dev/null +++ b/virtuerl/src/virtuerl_stor.erl @@ -0,0 +1,48 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_stor). + +-behaviour(gen_server). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). + +-define(SERVER, ?MODULE). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + {ok, Table} = dets:open_file(stors, []), + {ok, {Table}}. + +handle_call({domain_delete, #{id := DomainID}}, _From, State) -> + {Table} = State, + Res = dets:delete(Table, DomainID), + dets:sync(Table), + ok = supervisor:terminate_child(virtuerl_sup, DomainID), + ok = supervisor:delete_child(virtuerl_sup, DomainID), + ok = gen_server:call(virtuerl_net, {net_update}), + {reply, Res, State}. + +handle_cast(_Request, State) -> + {noreply, State}. + +handle_info(_Info, State) -> + {noreply, State}. + +terminate(_Reason, {Table}) -> + dets:close(Table), + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. diff --git a/virtuerl/src/virtuerl_util.erl b/virtuerl/src/virtuerl_util.erl index b06cad2..0880de6 100644 --- a/virtuerl/src/virtuerl_util.erl +++ b/virtuerl/src/virtuerl_util.erl @@ -10,10 +10,21 @@ -author("ilya-stroeer"). %% API --export([uuid4/0]). +-export([uuid4/0, mac_to_str/1, delete_file/1]). uuid4() -> ID = string:lowercase(binary:encode_hex(<<(rand:uniform(16#FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)-1):128>>)), <> = ID, Uuid4 = iolist_to_binary([A, "-", B, "-", C, "-", D, "-", E]), Uuid4. + +mac_to_str(<>) -> + <> = string:lowercase(binary:encode_hex(<>)), + <>. + +delete_file(Filename) -> + case file:delete(Filename) of + ok -> ok; + {error, enoent} -> ok; + Other -> Other + end. From f9676808d7643e2c8934d2840d486c584176d6b7 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 6 Jan 2024 17:13:06 +0100 Subject: [PATCH 33/51] virtuerl: fix CI setup --- .github/workflows/build.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4656183..992ae3e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -39,7 +39,8 @@ jobs: - name: Setup Virtuerl working-directory: virtuerl run: | - rebar3 release + sudo apt install -y g++ + sudo rebar3 release cat << EOF | sudo tee -a /etc/systemd/system/virtuerl.service [Unit] @@ -47,8 +48,9 @@ jobs: After=network.target [Service] + Environment="SHELL=/bin/sh" WorkingDirectory=${PWD}/_build/default/rel/virtuerl/ - ExecStart=bin/virtuerl foreground + ExecStart=${PWD}/_build/default/rel/virtuerl/bin/virtuerl foreground Restart=always [Install] From dc062c75c92a9b5d15bc5e85ece5ec614f904fe3 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 27 Jan 2024 00:24:25 +0100 Subject: [PATCH 34/51] virtuerl: init wxwidgets ui --- virtuerl/src/virtuerl_ipam.erl | 5 + virtuerl/src/virtuerl_mgt.erl | 32 +-- virtuerl/src/virtuerl_net.erl | 16 +- virtuerl/src/virtuerl_pubsub.erl | 52 +++++ virtuerl/src/virtuerl_qemu.erl | 88 +++++---- virtuerl/src/virtuerl_sup.erl | 10 +- virtuerl/src/virtuerl_ui.erl | 330 +++++++++++++++++++++++++++++++ virtuerl/src/virtuerl_vnc.erl | 239 ++++++++++++++++++++++ 8 files changed, 724 insertions(+), 48 deletions(-) create mode 100644 virtuerl/src/virtuerl_pubsub.erl create mode 100644 virtuerl/src/virtuerl_ui.erl create mode 100644 virtuerl/src/virtuerl_vnc.erl diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index a839199..3eb23a4 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -47,6 +47,7 @@ ipam_put_net(NetworkDef) -> Other end. +-spec ipam_list_nets() -> {ok, #{binary() => #{cidr4 | cidr6 := #{address := nonempty_binary(), prefixlen := integer()}}}}. ipam_list_nets() -> gen_server:call(ipam, net_list). @@ -197,6 +198,10 @@ handle_call({ip_put, NetworkId, IpAddr, DomainId}, _From, StoreId) -> end, {reply, R, StoreId}; +handle_call({ip_delete, NetworkId, IpAddr}, _From, StoreId) -> + R = khepri:delete(StoreId, [network, NetworkId, ?KHEPRI_WILDCARD_STAR, IpAddr]), + {reply, R, StoreId}; + handle_call({ip_clear}, _From, StoreId) -> R = khepri:delete(StoreId, [network]), {reply, R, StoreId}. diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 8aac529..b52c921 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -11,7 +11,7 @@ -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, handle_continue/2]). --export([create_vm/0, domain_create/1, domain_get/1, domain_delete/1, domain_stop/1, domain_start/1]). +-export([create_vm/0, domain_create/1, domain_get/1, domain_delete/1, domain_stop/1, domain_start/1, domains_list/0]). -export([home_path/0]). -define(SERVER, ?MODULE). @@ -30,8 +30,9 @@ domain_delete(Conf) -> domain_get(Conf) -> gen_server:call(?SERVER, {domain_get, Conf}). -domains_list(Conf) -> - gen_server:call(?SERVER, {domains_list, Conf}). +-spec domains_list() -> #{}. +domains_list() -> + gen_server:call(?SERVER, domains_list). domain_stop(Id) -> gen_server:call(?SERVER, {domain_update, #{id => Id, state => stopped}}). @@ -60,7 +61,8 @@ init([]) -> handle_continue(setup_base, State) -> ok = filelib:ensure_path(filename:join(home_path(), "domains")), - BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), +%% BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), + BaseImagePath = filename:join(home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"), case filelib:is_regular(BaseImagePath) of true -> ok; false -> @@ -108,12 +110,12 @@ generate_unique_tap_name(TapNames) -> handle_call({domain_create, Conf}, _From, State) -> {Table} = State, - #{network_id := NetworkID} = Conf, DomainID = virtuerl_util:uuid4(), - Domain = #{id => DomainID, network_id => NetworkID}, % TODO: save ipv4 addr as well + Domain = maps:merge(#{id => DomainID, name => DomainID}, Conf), % TODO: save ipv4 addr as well dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), + #{network_id := NetworkID} = Domain, {ok, #{cidrs := Cidrs}} = virtuerl_ipam:ipam_get_net(NetworkID), Keys = lists:map(fun(Cidr) -> {Ip, _} = virtuerl_net:parse_cidr(Cidr), @@ -151,8 +153,8 @@ handle_call({domain_create, Conf}, _From, State) -> Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #{tap_name := Tap} <- Domains]), TapName = generate_unique_tap_name(TapNames), - <> = <<(rand:uniform(16#ffffffffffff)):48>>, - MacAddr = <>, + <> = <<(rand:uniform(16#ffffffffffff)):48>>, + MacAddr = <>, dets:insert(Table, {DomainID, Domain#{network_addrs => Cidrs, mac_addr=>MacAddr, ipv4_addr=>Ipv4Addr, ipv6_addr => Ipv6Addr, cidrs => IpCidrs, tap_name => TapName}}), dets:sync(Table), @@ -171,18 +173,22 @@ handle_call({domain_create, Conf}, _From, State) -> handle_call({domain_update, #{id := DomainID, state := RunState}}, _From, {Table} = State) -> Reply = case dets:lookup(Table, DomainID) of [{_, Domain}] -> - ok = dets:insert(Table, {DomainID, Domain#{state := RunState}}), + ok = dets:insert(Table, {DomainID, Domain#{state => RunState}}), ok = dets:sync(Table), ok; [] -> notfound end, {reply, Reply, State, {continue, sync_domains}}; +handle_call(domains_list, _From, State) -> + {Table} = State, + Domains = dets:match_object(Table, '_'), + {reply, [maps:merge(#{state => stopped, name => Id}, Domain) || {Id, Domain} <- Domains], State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of - [{_, #{network_id := NetworkID, mac_addr := MacAddr, ipv4_addr:=IP, tap_name := TapName}}] -> - DomRet = #{network_id => NetworkID, mac_addr => binary:encode_hex(MacAddr), ipv4_addr => virtuerl_net:format_ip_bitstring(IP), tap_name => iolist_to_binary(TapName)}, - {ok, DomRet}; + [{_, #{mac_addr := MacAddr, ipv4_addr:=IP, tap_name := TapName} = Domain}] -> + DomRet = Domain#{mac_addr := binary:encode_hex(MacAddr), ipv4_addr := virtuerl_net:format_ip_bitstring(IP), tap_name := iolist_to_binary(TapName)}, + {ok, maps:merge(#{name => DomainID}, DomRet)}; [] -> notfound end, {reply, Reply, State}; @@ -190,7 +196,9 @@ handle_call({domain_delete, #{id := DomainID}}, _From, State) -> {Table} = State, Res = dets:delete(Table, DomainID), dets:sync(Table), + io:format("terminating ~p~n", [DomainID]), ok = supervisor:terminate_child(virtuerl_sup, DomainID), + io:format("done terminating ~p~n", [DomainID]), ok = supervisor:delete_child(virtuerl_sup, DomainID), ok = gen_server:call(virtuerl_net, {net_update}), {reply, Res, State}. diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 3a60067..01d9a5d 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -139,6 +139,11 @@ update_nftables(Domains) -> " type nat hook prerouting priority dstnat - 5; policy accept;\n", DnsRules, " }\n", + + " chain postrouting {\n", + " type nat hook postrouting priority -5; policy accept;\n", + " oifname != \"verlbr*\" iifname \"verlbr*\" masquerade\n", + " }\n", "}\n" ], io:format("~s~n", [IoList]), @@ -147,7 +152,11 @@ update_nftables(Domains) -> ok = filelib:ensure_dir(Path), ok = file:write_file(Path, IoList), - os:cmd(io_lib:format("nft -f ~s", [Path])), + NftOut = os:cmd(io_lib:format("nft -f ~s", [Path])), + case NftOut of + "" -> ok; + _ -> error({nft_error, NftOut}) + end, file:delete(Path). network_cidrs_to_bride_cidrs(Cidrs) -> @@ -249,6 +258,9 @@ generate_unique_bridge_name(Ifnames) -> generate_unique_bridge_name(Ifnames) end. +to_vtap_map(MacAddr) -> + <> = MacAddr, + <>. sync_taps(Domains) -> Output = os:cmd("ip -j addr"), @@ -262,7 +274,7 @@ sync_taps(Domains) -> TapsTarget = sets:from_list([iolist_to_binary(TapName) || {_, #{tap_name := TapName}} <- Domains]), % TODO: persist tap_name as binary io:format("Taps Target: ~p~n", [sets:to_list(TapsTarget)]), io:format("Taps Actual: ~p~n", [sets:to_list(TapsActual)]), - TapsMap = maps:from_list([{iolist_to_binary(Tap), {MacAddr, network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), + TapsMap = maps:from_list([{iolist_to_binary(Tap), {to_vtap_map(MacAddr), network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), diff --git a/virtuerl/src/virtuerl_pubsub.erl b/virtuerl/src/virtuerl_pubsub.erl new file mode 100644 index 0000000..1eaf844 --- /dev/null +++ b/virtuerl/src/virtuerl_pubsub.erl @@ -0,0 +1,52 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_pubsub). + +-behaviour(gen_server). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). +-export([subscribe/0, send/1]). + +-define(SERVER, ?MODULE). +-define(APPLICATION, virtuerl). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +subscribe() -> + gen_server:call(?SERVER, subscribe). + +send(Message) -> + gen_server:cast(?SERVER, {send, Message}). + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + {ok, []}. + +handle_call(subscribe, {Pid, _Tag}, State) -> + _Ref = monitor(process, Pid), + {reply, ok, [Pid | State]}. + +handle_cast({send, Message}, State) -> + [Pid ! Message || Pid <- State], + {noreply, State}. + +handle_info({'DOWN', Ref, process, Pid, Reason}, State) -> + io:format("~p died because of ~p~n", [Pid, Reason]), + NewState = lists:delete(Pid, State), + {noreply, NewState}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index 54def68..9ce0f7f 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -38,21 +38,23 @@ callback_mode() -> init([ID]) -> {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), - [{DomainId, #{mac_addr:=MacAddr, tap_name := TapName} = Domain}] = dets:lookup(Table, ID), + [{DomainId, #{mac_addr:=MacAddr, tap_name := TapName} = DomainRaw}] = dets:lookup(Table, ID), + Domain = maps:merge(#{user_data => ""}, DomainRaw), DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId]), ok = filelib:ensure_path(DomainHomePath), RootVolumePath = filename:join(DomainHomePath, "root.qcow2"), case filelib:is_regular(RootVolumePath) of false -> - BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), - exec:run(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s", [filename:absname(BaseImagePath), RootVolumePath])); +%% BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), + BaseImagePath = filename:join([virtuerl_mgt:home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"]), + exec:run(lists:flatten(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s", [filename:absname(BaseImagePath), RootVolumePath])), [sync]); _ -> noop end, process_flag(trap_exit, true), ensure_cloud_config(Domain), file:delete(filename:join(DomainHomePath, "qmp.sock")), file:delete(filename:join(DomainHomePath, "serial.sock")), - Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -display none -m 512 -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -display none -qmp unix:qmp.sock,server=on,wait=off -serial unix:serial.sock,server=on,wait=off"]), + Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc :1 -display none -serial none -m 512 -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off"]), % -serial unix:serial.sock,server=on,wait=off io:format("QEMU cmdline: ~s~n", [Cmd]), {ok, Pid, OsPid} = exec:run_link(Cmd, [{cd, DomainHomePath}]), State = #{table => Table, id => ID, domain => Domain, qemu_pid => {Pid, OsPid}, qmp_pid => undefined}, @@ -62,11 +64,27 @@ handle_continue(setup_qmp, #{id := ID} = State) -> QmpSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "qmp.sock"]), io:format("waiting for qmp.sock ~p~n", [erlang:timestamp()]), %% {ok, _} = exec:run(iolist_to_binary(["inotifywait -e create --include 'qmp\\.sock' ", ID]), [sync]), - ok = wait_for_socket(ID), - io:format("done waiting for qmp.sock ~p~n", [erlang:timestamp()]), - {ok, QmpPid} = virtuerl_qmp:start_link(QmpSocketPath, self()), - virtuerl_qmp:exec(QmpPid, cont), - {noreply, State#{qmp_pid => QmpPid}}. + case wait_for_socket(QmpSocketPath) of + ok -> + {ok, QmpPid} = virtuerl_qmp:start_link(QmpSocketPath, self()), + virtuerl_qmp:exec(QmpPid, cont), + {noreply, State#{qmp_pid => QmpPid}, {continue, setup_serial}}; + timeout -> + {stop, failure, State} + end; +handle_continue(setup_serial, #{id := ID} = State) -> + {noreply, State}. +%% SerialSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "serial.sock"]), +%% io:format("waiting for serial.sock ~p~n", [erlang:timestamp()]), +%%%% {ok, _} = exec:run(iolist_to_binary(["inotifywait -e create --include 'qmp\\.sock' ", ID]), [sync]), +%% case wait_for_socket(SerialSocketPath) of +%% ok -> +%% % TODO: shall this be its own process instead? +%% {ok, SerialSocket} = gen_tcp:connect({local, SerialSocketPath}, 0, [local, {active, true}, {packet, line}, binary]), +%% {noreply, State#{serial_socket => SerialSocket}}; +%% timeout -> +%% {stop, failure, State} +%% end. handle_info({qmp, Event}, #{table := Table, id := ID, domain := Domain} = State) -> io:format("QMP: ~p~n", [Event]), @@ -78,7 +96,10 @@ handle_info({qmp, Event}, #{table := Table, id := ID, domain := Domain} = State) ok = dets:sync(Table), {stop, normal, State#{domain => DomainUpdated}}; _ -> {noreply, State} - end. + end; +handle_info({tcp, SerialSocket, Data}, #{table := Table, id := ID, domain := Domain, serial_socket := SerialSocket} = State) -> + virtuerl_pubsub:send({domain_out, ID, Data}), + {noreply, State}. shutdown_events() -> receive @@ -127,14 +148,29 @@ terminate(_Reason, #{table := Table, id := ID, domain := Domain, qemu_pid := {Pi %%% Internal functions %%%=================================================================== -wait_for_socket(ID) -> - QmpSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "qmp.sock"]), +wait_for_socket(SocketPath) -> + Self = self(), + WaiterPid = spawn(fun () -> + do_wait_for_socket(SocketPath, Self) + end), + receive + {virtuerl, socket_available} -> + io:format("done waiting for ~s ~p~n", [SocketPath, erlang:timestamp()]), + ok + after 2000 -> + io:format("failed waiting"), + exit(WaiterPid, kill), + timeout + end. + +do_wait_for_socket(SocketPath, Requester) -> io:format("checking...~n"), - case filelib:last_modified(QmpSocketPath) of + case filelib:last_modified(SocketPath) of 0 -> timer:sleep(20), - wait_for_socket(ID); - _ -> ok + do_wait_for_socket(SocketPath, Requester); + _ -> + Requester ! {virtuerl, socket_available} end. ensure_cloud_config(#{id := DomainID} = Domain) -> @@ -143,7 +179,7 @@ ensure_cloud_config(#{id := DomainID} = Domain) -> false -> create_cloud_config(Domain) end. -create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs}) -> +create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs, user_data := UserData}) -> NetConf = [ "version: 2\n", "ethernets:\n", @@ -154,30 +190,16 @@ create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs}) -> " dhcp4: false\n", " dhcp6: false\n", " addresses:\n", [[ - " - ", virtuerl_net:format_ip(IpAddr), "/", integer_to_binary(Prefixlen), "\n"] || {IpAddr, Prefixlen} <- Cidrs], + " - ", virtuerl_net:format_ip(IpAddr), "/", integer_to_binary(Prefixlen), "\n"] || {IpAddr, Prefixlen} <- Cidrs], " routes:\n", [[ - " - to: default\n", - " via: ", virtuerl_net:format_ip(virtuerl_net:bridge_addr(IpAddr, Prefixlen)), "\n"] || {IpAddr, Prefixlen} <- Cidrs], + " - to: default\n", + " via: ", virtuerl_net:format_ip(virtuerl_net:bridge_addr(IpAddr, Prefixlen)), "\n"] || {IpAddr, Prefixlen} <- Cidrs], "" ], MetaData = [ "instance-id: ", DomainID, "\n", "local-hostname: ", DomainID, "\n" ], - % openssl passwd -6 - UserData = [ - "#cloud-config\n", - "users:\n", - " - default\n", - " - name: ilya\n", - " passwd: $6$VAKAlO91OquUA1ON$4w2.omQG9OUt0KuMtCvYrJgervyK8WZrTMFUhJI2fXTsfMN5YvuxKaZbSJTXkJvq4qAiFHptt6zKg2hTMOrkH0\n", - " lock_passwd: false\n", - " shell: /bin/bash\n", - " sudo: ALL=(ALL) NOPASSWD:ALL\n", - " ssh_authorized_keys:\n", - " - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCKxHNpVg1whPegPv0KcRQTOfyVIqLwvMfVLyT9OpBPXHDudsFz9soOgMUEyWm8ZJ+pJ9fRCg66B+D5/ZRTwJCBpyNncfXCwu8xEJgEeoIubObh6t6dHWqqxX/yhHAS5GIRUSypm78qg6V+SQ6SeJXSjOCLAbZmhyWgJrlDm9M6GTPQhPAztrgsCUrzxIpZ5el5BwJXrm3I+LOmofAUqgbLQz9HuGJzPpnfABDa9WoVfI0L7oTr0qGpWwx8l71b2s8AYl7GMD/bEkZKyi9SSwEVCHA88F7dYYrZ3+fMXE/mJf+v0ece2lIDT7Te1gtqiLu/izJNmqD+b6mtnnXxVxNOtynhv3t6uLE9kBX22SBCCRqPJzETGNXvYH6fATEe88dhLh8kTppLRB5UGUd/zztxuNBSpMwFXaq8SlTKURxvF8BuFIPCz0FW8fq+TA/xZfBYsiVt59jXgl6BQyEGY4bMuMtT2nD8QXwZ5vsj52mzKGJwBwduiaX302brHYUyQkuyLII5iqmCNZ5YLlMY76a61Yg9pWMeRwQscSO2k4a18GOo+sIrQVTyUQiT3KhRRaDNrZuCPicQRgkJuiS1fKt1cWjnOlyweLxSYbpKnoS0H7vt+NrtbU1u9FPknXQPQ0pxixPpV3zgUdfOLmisFH7WGVjwNVvZAlNc5uyqm0fbw== ilya@verbit.io\n", - "" - ], DomainBasePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), IsoBasePath = filename:join(DomainBasePath, "iso"), ok = filelib:ensure_path(IsoBasePath), diff --git a/virtuerl/src/virtuerl_sup.erl b/virtuerl/src/virtuerl_sup.erl index fec95ef..72f6acb 100644 --- a/virtuerl/src/virtuerl_sup.erl +++ b/virtuerl/src/virtuerl_sup.erl @@ -29,7 +29,15 @@ init([]) -> SupFlags = #{strategy => one_for_one, intensity => 300, period => 5}, - ChildSpecs = [{ + ChildSpecs = [ + { + virtuerl_pubsub, + {virtuerl_pubsub, start_link, []}, + permanent, + infinity, + worker, + [] + }, { virtuerl_ipam, {virtuerl_ipam, start_link, []}, permanent, diff --git a/virtuerl/src/virtuerl_ui.erl b/virtuerl/src/virtuerl_ui.erl new file mode 100644 index 0000000..ca2238f --- /dev/null +++ b/virtuerl/src/virtuerl_ui.erl @@ -0,0 +1,330 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009-2021. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +%%%------------------------------------------------------------------- +%%% File : hello.erl +%%% Author : Matthew Harrison +%%% Description : _really_ minimal example of a wxerlang app +%%% implemented with wx_object behaviour +%%% +%%% Created : 18 Sep 2008 by Matthew Harrison +%%% Dan rewrote it to show wx_object behaviour +%%%------------------------------------------------------------------- +-module(virtuerl_ui). +-include_lib("wx/include/wx.hrl"). + +-export([start/0, + init/1, handle_info/2, handle_event/2, handle_call/3, + code_change/3, terminate/2]). + +-behaviour(wx_object). + +-record(state, {win, info_panel, info, domain_panel, domain_info, toolbar, domain_list_box, domains}). + +start() -> + wx_object:start_link(?MODULE, [], []). + +%% Init is called in the new process. +init([]) -> + virtuerl_pubsub:subscribe(), + + wx:new(), + Frame = wxFrame:new(wx:null(), + -1, % window id + "Hello World", % window title + []), + + MenuBar = wxMenuBar:new(), + Menu = wxMenu:new(), + wxMenu:append(Menu, ?wxID_EXIT, "Quit"), + wxMenuBar:append(MenuBar, Menu, "File"), + wxFrame:setMenuBar(Frame, MenuBar), + wxFrame:connect(Frame, command_menu_selected), + + {Mx, My, _, _} = wxMiniFrame:getTextExtent(Frame, "M"), + wxFrame:setClientSize(Frame, {60*Mx, 20*My}), + + PlayIconDC = wxMemoryDC:new(), + PlayIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(PlayIconDC, PlayIcon), + wxMemoryDC:setBrush(PlayIconDC, ?wxGREEN_BRUSH), + wxMemoryDC:setPen(PlayIconDC, ?wxGREEN_PEN), + wxMemoryDC:drawPolygon(PlayIconDC, [{0,0},{30,15},{0,30}]), + wxMemoryDC:destroy(PlayIconDC), + PlayIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(PlayIcon))), + + StopIconDC = wxMemoryDC:new(), + StopIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(StopIconDC, StopIcon), + wxMemoryDC:setBrush(StopIconDC, ?wxRED_BRUSH), + wxMemoryDC:setPen(StopIconDC, ?wxRED_PEN), + wxMemoryDC:drawRectangle(StopIconDC, {0,0},{30,30}), + wxMemoryDC:destroy(StopIconDC), + StopIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(StopIcon))), + + Toolbar = wxFrame:createToolBar(Frame), + wxToolBar:addTool(Toolbar, 100, "test123", PlayIcon, PlayIconDisabled), + wxToolBar:enableTool(Toolbar, 100, false), + wxToolBar:addTool(Toolbar, 101, "test123", StopIcon, StopIconDisabled), + wxToolBar:enableTool(Toolbar, 101, false), + wxToolBar:realize(Toolbar), + wxToolBar:connect(Toolbar, command_menu_selected), + + wxFrame:createStatusBar(Frame,[]), + + %% if we don't handle this ourselves, wxwidgets will close the window + %% when the user clicks the frame's close button, but the event loop still runs + wxFrame:connect(Frame, close_window), + + RootPanel = wxPanel:new(Frame, [{size, wxFrame:getSize(Frame)}]), + Notebook = wxNotebook:new(RootPanel, ?wxID_ANY), + + Sizer = wxBoxSizer:new(?wxHORIZONTAL), + wxSizer:add(Sizer, Notebook, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxPanel:setSizer(RootPanel, Sizer), + + + NetworkPanel = wxPanel:new(Notebook, []), + NetworksSizer = wxBoxSizer:new(?wxHORIZONTAL), + NetworkSplitter = wxSplitterWindow:new(NetworkPanel), + wxSizer:add(NetworksSizer, NetworkSplitter, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxPanel:setSizer(NetworkPanel, NetworksSizer), + + wxNotebook:addPage(Notebook, NetworkPanel, "Networks"), + + {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + Choices = maps:keys(Nets), + ListBox = wxListBox:new(NetworkSplitter, 42, [{choices, Choices}]), + wxListBox:connect(ListBox, command_listbox_selected), % command_listbox_doubleclicked + + Info = wxPanel:new(NetworkSplitter), + InfoSizer = wxBoxSizer:new(?wxHORIZONTAL), + InfoGrid = wxFlexGridSizer:new(3, 2, 0, 0), + wxSizer:add(InfoSizer, InfoGrid, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxPanel:setSizer(Info, InfoSizer), + + wxSplitterWindow:splitVertically(NetworkSplitter, ListBox, Info, [{sashPosition, 25 * Mx}]), + + % BEGIN Domains + DomainPanel = wxPanel:new(Notebook, []), + DomainsSizer = wxBoxSizer:new(?wxHORIZONTAL), + DomainSplitter = wxSplitterWindow:new(DomainPanel), + wxSizer:add(DomainsSizer, DomainSplitter, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxPanel:setSizer(DomainPanel, DomainsSizer), + + wxNotebook:addPage(Notebook, DomainPanel, "Domains"), + wxNotebook:setSelection(Notebook, 1), + + Domains = virtuerl_mgt:domains_list(), + ColumnNames = ["ID", "Name", "IPs"], + DomainsTuples = [{Id, Name, lists:join($,, [virtuerl_net:format_ip(Ip) || {Ip, _Prefixlen} <- Cidrs])} || #{id := Id, name := Name, cidrs := Cidrs} <- Domains], + DomainsIds = [Id || {Id, _Name, _} <- DomainsTuples], + DomainListBox = wxListCtrl:new(DomainSplitter, [{style, ?wxLC_REPORT}]), + lists:foreach(fun ({Idx, Name}) -> wxListCtrl:insertColumn(DomainListBox, Idx, Name) end, lists:enumerate(0, ColumnNames)), + lists:foreach(fun (Idx) -> + Item = wxListItem:new(), + wxListItem:setId(Item, Idx), + wxListCtrl:insertItem(DomainListBox, Item) + end, lists:seq(1, length(DomainsTuples))), + lists:foreach(fun (ColIdx) -> + lists:foreach(fun ({RowIdx, Dom}) -> + wxListCtrl:setItem(DomainListBox, RowIdx, ColIdx - 1, element(ColIdx, Dom)) + end, lists:enumerate(0, DomainsTuples)) + end, lists:seq(1, length(ColumnNames))), + wxListCtrl:connect(DomainListBox, command_list_item_selected), % command_listbox_doubleclicked + + DomainInfo = wxPanel:new(DomainSplitter), + DomainInfoSizer = wxBoxSizer:new(?wxVERTICAL), +%% DomainInfoGrid = wxFlexGridSizer:new(3, 2, 0, 0), + DomainInfoGrid = wxGridBagSizer:new(), + wxSizer:add(DomainInfoSizer, DomainInfoGrid, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxPanel:setSizer(DomainInfo, DomainInfoSizer), + + DomainButtonsSizer = wxBoxSizer:new(?wxHORIZONTAL), + DomainDupBtn = wxButton:new(DomainInfo, 4044, [{label, "Duplicate"}]), + + wxButton:connect(DomainDupBtn, command_button_clicked), + DomainDelBtn = wxButton:new(DomainInfo, ?wxID_ANY, [{label, "Delete"}]), + wxSizer:add(DomainButtonsSizer, DomainDupBtn), + wxSizer:add(DomainButtonsSizer, DomainDelBtn), + wxSizer:add(DomainInfoSizer, DomainButtonsSizer, [{flag, ?wxALIGN_RIGHT}]), + + wxSplitterWindow:splitVertically(DomainSplitter, DomainListBox, DomainInfo, [{sashPosition, 25 * Mx}]), + % END Domains + + ok = wxFrame:setStatusText(Frame, "Hello World!",[]), + wxWindow:fit(Frame), + wxWindow:show(Frame), + wxWindow:raise(Frame), + wxWindow:setFocus(Frame), + wxWindow:layout(Frame), + {Frame, #state{win=Frame, info_panel = Info, info=InfoGrid, domain_panel = DomainInfo, domain_info=DomainInfoGrid, domain_list_box=DomainListBox, toolbar=Toolbar, domains = DomainsIds}}. + + +%% Handled as in normal gen_server callbacks +handle_info({domain_out, _Id, Text}, #state{domain_panel = DomainPanel} = State) -> + SerialOut = wx:typeCast(wxPanel:findWindow(DomainPanel, 69), wxStyledTextCtrl), + io:put_chars(Text), + wxStyledTextCtrl:appendText(SerialOut, Text), + wxStyledTextCtrl:scrollToLine(SerialOut, wxStyledTextCtrl:getLineCount(SerialOut)), + {noreply,State}; +handle_info(Msg, #state{domain_panel = DomainPanel} = State) -> + io:format("Got Info ~p~n",[Msg]), + {noreply, State}. + +handle_call(Msg, _From, State) -> + io:format("Got Call ~p~n",[Msg]), + {reply,ok,State}. + +%% Async Events are handled in handle_event as in handle_info +handle_event(#wx{id = 42, event = #wxCommand{type = command_listbox_selected, + cmdString = Choice}}, + State = #state{info_panel = Panel, info=Info, domains = DomainIds}) -> + {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + Net = maps:get(list_to_binary(Choice), Nets), + #{cidr4 := #{address := Address, prefixlen := Prefixlen}} = Net, + wxFlexGridSizer:clear(Info, [{delete_windows, true}]), + wxSizer:add(Info, wxStaticText:new(Panel, -1, "CIDR")), + wxSizer:add(Info, wxStaticText:new(Panel, -1, iolist_to_binary([Address, "/", integer_to_binary(Prefixlen)]))), + io:format("dblclick ~p (~p)~n", [Choice, Net]), + {noreply, State}; +handle_event(#wx{event = #wxList{type = command_list_item_selected, + itemIndex = ItemIndex}}, + State = #state{domain_panel = DomainPanel, domain_info = DomainInfo, toolbar=Toolbar, domains = DomainIds}) -> + Domains = maps:from_list([{Id, Domain} || Domain = #{id := Id} <- virtuerl_mgt:domains_list()]), + wxGridBagSizer:clear(DomainInfo, [{delete_windows, true}]), + + DomainId = lists:nth(ItemIndex + 1, DomainIds), + Domain = maps:get(DomainId, Domains), + #{state := DomainState, network_id := NetworkId} = Domain, + case DomainState of + running -> + wxToolBar:enableTool(Toolbar, 100, false), + wxToolBar:enableTool(Toolbar, 101, true); + stopped -> + wxToolBar:enableTool(Toolbar, 100, true), + wxToolBar:enableTool(Toolbar, 101, false) + end, + wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, "ID"), {0, 0}), + wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, DomainId), {0, 1}), + wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, "Network ID"), {1, 0}), + wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, NetworkId), {1, 1}), + + DomainWithoutUserData = maps:remove(user_data, Domain), + wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, io_lib:format("~p", [DomainWithoutUserData])), {2, 0}, [{span, {1, 2}}]), + +%% SerialOut = wxStyledTextCtrl:new(DomainPanel, [{id, 69}]), +%% wxStyledTextCtrl:setLexer(SerialOut, ?wxSTC_LEX_ERRORLIST), +%% wxStyledTextCtrl:styleSetVisible(SerialOut, 23, false), +%% wxStyledTextCtrl:styleSetVisible(SerialOut, 24, false), +%% wxStyledTextCtrl:setProperty(SerialOut, "lexer.errorlist.value.separate", "0"), +%% wxStyledTextCtrl:setProperty(SerialOut, "lexer.errorlist.escape.sequences", "1"), +%% wxGridBagSizer:add(DomainInfo, SerialOut, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), +%% WebView = wxWebView:new(DomainPanel, 999, [{url, "http://0.0.0.0:9000/noVNC-1.4.0/vnc.html?port=5700&?path=&resize=scale&autoconnect=true"}]), +%% wxGridBagSizer:add(DomainInfo, WebView, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), + VncWindow = virtuerl_vnc:start(DomainPanel), + wxGridBagSizer:add(DomainInfo, VncWindow, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), + + wxGridBagSizer:addGrowableRow(DomainInfo, 3), + + UserData = maps:get(user_data, Domain, ""), + UserDataCtrl = wxStyledTextCtrl:new(DomainPanel), + wxStyledTextCtrl:setScrollWidth(UserDataCtrl, wxStyledTextCtrl:textWidth(UserDataCtrl, wxStyledTextCtrl:getStyleAt(UserDataCtrl, 0), UserData)), + wxStyledTextCtrl:setText(UserDataCtrl, list_to_binary(UserData)), + wxStyledTextCtrl:setReadOnly(UserDataCtrl, true), + LastRowIndex = 4, +%% Msg = wxNotificationMessage:new(lists:flatten(io_lib:format("LastRowIndex: ~p~n", [LastRowIndex]))), +%% wxNotificationMessage:show(Msg), + wxGridBagSizer:add(DomainInfo, UserDataCtrl, {LastRowIndex, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), + wxGridBagSizer:addGrowableRow(DomainInfo, LastRowIndex), + wxGridBagSizer:addGrowableCol(DomainInfo, 1), + wxPanel:layout(DomainPanel), + io:format("dblclick ~p (~p)~n", [DomainId, Domain]), + {noreply, State}; +handle_event(#wx{id = 4044, event = #wxCommand{type = command_button_clicked}}, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> + SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), + DomainId = lists:nth(SelectedItem + 1, DomainIds), + {ok, Domain} = virtuerl_mgt:domain_get(#{id => DomainId}), + create_domain_dialog(Domain), + {noreply, State}; +handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> + io:format("~p~n", [Event]), + SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), + DomainId = lists:nth(SelectedItem + 1, DomainIds), + Choice = DomainId, + io:format("~p~n", [Choice]), + wxToolBar:enableTool(Toolbar, 100, false), + wxToolBar:enableTool(Toolbar, 101, true), + ok = virtuerl_mgt:domain_start(Choice), + {noreply, State}; +handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> + io:format("~p~n", [Event]), + SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), + DomainId = lists:nth(SelectedItem + 1, DomainIds), + Choice = DomainId, + io:format("~p~n", [Choice]), + wxToolBar:enableTool(Toolbar, 100, true), + wxToolBar:enableTool(Toolbar, 101, false), + ok = virtuerl_mgt:domain_stop(Choice), + {noreply, State}; +handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) -> + io:format("~p Closing window ~n",[self()]), + ok = wxFrame:setStatusText(Frame, "Closing...",[]), + wxWindow:destroy(Frame), + {stop, normal, State}; +handle_event(#wx{id = ?wxID_EXIT, event = #wxCommand{type = command_menu_selected}}, State = #state{win=Frame}) -> + io:format("~p Quitting window ~n",[self()]), + ok = wxFrame:setStatusText(Frame, "Closing...",[]), + wxWindow:destroy(Frame), + {stop, normal, State}. + +code_change(_, _, State) -> + {stop, not_yet_implemented, State}. + +terminate(_Reason, _State) -> + ok. + +create_domain_dialog(#{network_id := NetworkId, user_data := UserData} = Domain) -> + {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + Choices = maps:keys(Nets), + Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Domain", [{size, {1000, 500}}]), + DialogSizer = wxBoxSizer:new(?wxVERTICAL), + DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Network")), + NetworkChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, Choices}]), + wxChoice:setStringSelection(NetworkChoice, NetworkId), + wxSizer:add(DialogGridSizer, NetworkChoice), + wxSizer:add(DialogSizer, DialogGridSizer), + UserDataCtrl = wxStyledTextCtrl:new(Dialog), + wxStyledTextCtrl:setLexer(UserDataCtrl, ?wxSTC_LEX_YAML), + wxStyledTextCtrl:setText(UserDataCtrl, UserData), + wxSizer:add(DialogSizer, UserDataCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), + ButtonSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL), + wxSizer:add(DialogSizer, ButtonSizer), + wxPanel:setSizer(Dialog, DialogSizer), + + case wxDialog:showModal(Dialog) of + ?wxID_OK -> + io:format("true ~p~n", [wxChoice:getStringSelection(NetworkChoice)]), + virtuerl_mgt:domain_create(#{network_id => list_to_binary(wxChoice:getStringSelection(NetworkChoice)), user_data => wxStyledTextCtrl:getText(UserDataCtrl)}); + _ -> ok + end, + wxDialog:destroy(Dialog); +create_domain_dialog(Domain) -> + create_domain_dialog(Domain#{user_data => ""}). diff --git a/virtuerl/src/virtuerl_vnc.erl b/virtuerl/src/virtuerl_vnc.erl new file mode 100644 index 0000000..02caf79 --- /dev/null +++ b/virtuerl/src/virtuerl_vnc.erl @@ -0,0 +1,239 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009-2021. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +%%%------------------------------------------------------------------- +%%% File : hello.erl +%%% Author : Matthew Harrison +%%% Description : _really_ minimal example of a wxerlang app +%%% implemented with wx_object behaviour +%%% +%%% Created : 18 Sep 2008 by Matthew Harrison +%%% Dan rewrote it to show wx_object behaviour +%%%------------------------------------------------------------------- +-module(virtuerl_vnc). +-include_lib("wx/include/wx.hrl"). +-include_lib("wx/include/gl.hrl"). + +-export([ + init/1, handle_info/2, handle_event/2, + code_change/3, terminate/2]). +-export([start/1]). + +-behaviour(wx_object). + +-define(vncINVALID, 0). +-define(vncNONE, 1). +-define(vncVNC_AUTH, 2). +-define(vncOK, 0). +-define(vncFAILED, 1). +-define(vncMSG_TYPE_FramebufferUpdate, 0). +-define(vncMSG_TYPE_FramebufferUpdateRequest, 3). +-define(vncMSG_TYPE_KeyEvent, 4). +-define(vncMSG_TYPE_PointerEvent, 5). +-define(vncENCODING_RAW, 0). + +-record(state, {win, socket, panel, tex_id, vnc_conf}). +-record(vnc_conf, {width, height}). + +start(Parent) -> + wx_object:start_link(?MODULE, [Parent], []). + +%% Init is called in the new process. +init([Parent]) -> + {ok, Socket} = gen_tcp:connect("localhost", 5901, [{active, true}, binary]), + receive + {tcp, Socket, <<"RFB ", Major:3/binary, ".", Minor:3/binary, "\n">>} -> + io:format("Major: ~s / Minor: ~s~n", [Major, Minor]), + ok + after 2000 -> + timeout + end, + + ok = gen_tcp:send(Socket, <<"RFB 003.008\n">>), + receive + {tcp, Socket, <>} -> + io:format("AuthType: ~p~n", [AuthType]), + case AuthType of + ?vncINVALID -> {error, auth_invalid}; + ?vncNONE -> ok; + ?vncVNC_AUTH -> {error, auth_not_supported}; + _ -> io:format("Unknown auth: ~p~n", [AuthType]) + end + after 2000 -> + {error, timeout} + end, + + ok = gen_tcp:send(Socket, <>), + receive + {tcp, Socket, <>} -> + io:format("Security result: ~B~n", [SecurityResult]), + case SecurityResult of + ?vncOK -> ok; + ?vncFAILED -> error + end + after 2000 -> + {error, timeout} + end, + + ok = gen_tcp:send(Socket, <<1>>), + VncConf = receive + {tcp, Socket, <>} -> + io:format("~s: ~Bx~B~n~B/~B (BE: ~B, TC: ~B)~nR:(X>>~B)&~B G:(X>>~B)&~B B:(X>>~B)&~B~n", [Name, Width, Height, Depth, BitsPerPixel, BigEndianFlag, TrueColorFlag, RedShift, RedMax, GreenShift, GreenMax, BlueShift, BlueMax]), + #vnc_conf{width = Width, height = Height} + after 2000 -> + {error, timeout} + end, + #vnc_conf{width = VncWidth, height = VncHeight} = VncConf, +%% #vnc_conf{width = Width, height = Height} = #vnc_conf{width = 800, height = 600}, + inet:setopts(Socket, [{active, once}]), + ok = gen_tcp:send(Socket, <>), + + {Mx, My, _, _} = wxWindow:getTextExtent(Parent, "M"), +%% wxFrame:setClientSize(Frame, {60*Mx, 20*My}), + Panel = wxGLCanvas:new(Parent, [{attribList, [?WX_GL_RGBA,?WX_GL_DOUBLEBUFFER,0]}]), + Context = wxGLContext:new(Panel), +%% wxWindow:setMinSize(Panel, {VncWidth, VncHeight}), + + wxGLCanvas:connect(Panel, key_down), + wxGLCanvas:connect(Panel, key_up), + + wxGLCanvas:setCurrent(Panel, Context), + +gl:enable(?GL_TEXTURE_2D), + [TexId] = gl:genTextures(1), + io:format("TEXTURE ID: ~p~n", [TexId]), + gl:bindTexture(?GL_TEXTURE_2D, TexId), + gl:texImage2D(?GL_TEXTURE_2D, 0, ?GL_RGB, VncWidth, VncHeight, 0, ?GL_RGB, ?GL_UNSIGNED_BYTE, 0), + gl:texParameteri(?GL_TEXTURE_2D,?GL_TEXTURE_MIN_FILTER,?GL_LINEAR), + Err = gl:getError(), + io:format("ERROR: ~p~n", [glu:errorString(Err)]), + wxGLCanvas:connect(Panel, erase_background, [{callback, fun(_,_) -> ok end}]), + wxGLCanvas:connect(Panel, paint), + {Panel, #state{socket=Socket, panel = Panel, tex_id = TexId, vnc_conf = VncConf}}. + +read_rects(0, _, Socket) -> + []; +read_rects(NumRects, Data, Socket) -> + case Data of + <> -> + case Encoding of + ?vncENCODING_RAW -> + NumBytes = Width * Height * 4, + case NumBytes > byte_size(Rest) of + true -> + BytesToFetch = NumBytes - byte_size(Rest) + (NumRects - 1) * 12, + {ok, MoreData} = gen_tcp:recv(Socket, BytesToFetch), + read_rects(NumRects, <>, Socket); + false -> + <> = Rest, + Rect = {X, Y, Width, Height, PixelBytes}, + Rects = read_rects(NumRects - 1, ActualRest, Socket), + [Rect | Rects] + end; + _ -> io:format("Unsupported encoding ~p~n", [Encoding]) + end; + _ -> + {ok, MoreData} = gen_tcp:recv(Socket, 12 - byte_size(Data) + (NumRects - 1) * 12), + read_rects(NumRects, <>, Socket) + end. + +%% Handled as in normal gen_server callbacks +handle_info({tcp, Socket, <>}, #state{panel = Panel, tex_id = TexId, vnc_conf = #vnc_conf{width = Width, height = Height}} = State) -> + {TimeRects, Rects} = timer:tc(fun() -> read_rects(NumRects, Rest, Socket) end), + {TimeRes, _} = timer:tc(fun() -> + wx:batch(fun() -> + gl:bindTexture(?GL_TEXTURE_2D, TexId), + [gl:texSubImage2D(?GL_TEXTURE_2D, 0, X, Y, Width, Height, ?GL_BGRA, ?GL_UNSIGNED_BYTE, Data) || {X, Y, Width, Height, Data} <- Rects] + end), + gl:flush() + end), + wxPanel:refresh(Panel, [{eraseBackground, false}]), +%% io:format("Writing rects took ~p/~p~n", [TimeRects, TimeRes]), + + inet:setopts(Socket, [{active, once}]), + ok = gen_tcp:send(Socket, <>), + {noreply, State}; + +handle_info(Msg, State) -> + io:format("Got Info ~p~n",[Msg]), + {noreply,State}. + +handle_event(#wx{event=#wxPaint{type = paint}, obj = _Obj}, State = #state{win=Frame, panel=Panel, tex_id = TexId, vnc_conf = #vnc_conf{width = Width, height = Height}}) -> + {W, H} = wxGLCanvas:getSize(_Obj), + Wscale = W / Width, + Hscale = H / Height, + {Scale, Xt, Yt} = case Wscale > Hscale of + true -> + {Hscale, max((W - Width*Hscale) / 2, 0), 0}; + false -> + {Wscale, 0, max((H - Height*Wscale) / 2, 0)} + end, + + {ScaleX, ScaleY} = {Width * Scale / W, Height * Scale / H}, + gl:viewport(0,0,W,H), + + gl:matrixMode(?GL_MODELVIEW), + gl:loadIdentity(), + gl:scalef(ScaleX, ScaleY, 0.0), + gl:clearColor(0.2, 0.2, 0.2, 1.0), + gl:clear(?GL_COLOR_BUFFER_BIT bor ?GL_DEPTH_BUFFER_BIT), + gl:bindTexture(?GL_TEXTURE_2D, TexId), + gl:enable(?GL_TEXTURE_2D), + gl:'begin'(?GL_QUADS), + + gl:texCoord2f(0.0, 1.0), + gl:vertex2f(-1.0, -1.0), + gl:texCoord2f(0.0, 0.0), + gl:vertex2f(-1.0, 1.0), + gl:texCoord2f(1.0, 0.0), + gl:vertex2f( 1.0, 1.0), + gl:texCoord2f(1.0, 1.0), + gl:vertex2f( 1.0, -1.0), + + gl:'end'(), + gl:flush(), + wxGLCanvas:swapBuffers(_Obj), + {noreply, State}; +handle_event(#wx{event=#wxKey{type = Type, keyCode = KeyCode, rawCode = Key}} = Event, State = #state{win=Frame, panel=Panel, socket = Socket}) -> + io:format("Event ~p~n", [Event]), + DownFlag = case Type of + key_down -> 1; + key_up -> 0 + end, + ok = gen_tcp:send(Socket, <>), + {noreply, State}; +handle_event(#wx{id = ?wxID_EXIT, event = #wxCommand{type = command_menu_selected}}, State = #state{win=Frame}) -> + io:format("~p Quitting window ~n",[self()]), + ok = wxFrame:setStatusText(Frame, "Closing...",[]), + wxWindow:destroy(Frame), + {stop, normal, State}; +handle_event(Event, State) -> + io:format("Got Event ~p~n",[Event]), + {noreply, State}. + +code_change(_, _, State) -> + {stop, not_yet_implemented, State}. + +terminate(_Reason, _State) -> + ok. From 8fc0b7e5d2d8163fd47dbc26e6331b3213c92db3 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sun, 11 Feb 2024 00:11:08 +0100 Subject: [PATCH 35/51] virtuerl: more steps towards a MVP --- virtuerl/src/virtuerl_ipam.erl | 10 ++ virtuerl/src/virtuerl_mgt.erl | 17 +-- virtuerl/src/virtuerl_net.erl | 6 +- virtuerl/src/virtuerl_qemu.erl | 18 +-- virtuerl/src/virtuerl_ui.erl | 189 +++++++++++++++++++++------- virtuerl/src/virtuerl_vnc.erl | 123 ++++-------------- virtuerl/src/virtuerl_vnc_proxy.erl | 143 +++++++++++++++++++++ 7 files changed, 348 insertions(+), 158 deletions(-) create mode 100644 virtuerl/src/virtuerl_vnc_proxy.erl diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index 3eb23a4..b332565 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -8,6 +8,7 @@ -behavior(gen_server). -export([req/1, init/1, handle_call/3, subnet/1, get_range/1, get_next/6, terminate/2, ipam_next_ip/1, start_server/1, stop_server/1, ipam_put_net/1, start_link/0, handle_cast/2, ipam_delete_net/1, ipam_create_net/1, ipam_list_nets/0, ipam_get_net/1, ipam_put_ip/3, assign_next/3]). +-export([unassign/1]). -include_lib("khepri/include/khepri.hrl"). -include_lib("khepri/src/khepri_error.hrl"). @@ -51,6 +52,8 @@ ipam_put_net(NetworkDef) -> ipam_list_nets() -> gen_server:call(ipam, net_list). +ipam_delete_net(ID) when is_list(ID) -> + ipam_delete_net(list_to_binary(ID)); ipam_delete_net(ID) -> case gen_server:call(ipam, {net_delete, ID}) of {ok, Res} -> @@ -82,6 +85,9 @@ assign_next(NetworkID, Tag, VMID) -> Other end. +unassign(DomainId) -> + gen_server:call(ipam, {unassign, DomainId}). + ipam_next_ip(NetworkName) -> case gen_server:call(ipam, {ip_next, NetworkName}) of {ok, Res} -> @@ -202,6 +208,10 @@ handle_call({ip_delete, NetworkId, IpAddr}, _From, StoreId) -> R = khepri:delete(StoreId, [network, NetworkId, ?KHEPRI_WILDCARD_STAR, IpAddr]), {reply, R, StoreId}; +handle_call({unassign, DomainId}, _From, StoreId) -> + ok = khepri:delete_many(StoreId, [network, ?KHEPRI_WILDCARD_STAR, ?KHEPRI_WILDCARD_STAR, #if_data_matches{pattern = DomainId}]), + {reply, ok, StoreId}; + handle_call({ip_clear}, _From, StoreId) -> R = khepri:delete(StoreId, [network]), {reply, R, StoreId}. diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index b52c921..31b4d4f 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -61,8 +61,8 @@ init([]) -> handle_continue(setup_base, State) -> ok = filelib:ensure_path(filename:join(home_path(), "domains")), -%% BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), - BaseImagePath = filename:join(home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"), + BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), +%% BaseImagePath = filename:join(home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"), case filelib:is_regular(BaseImagePath) of true -> ok; false -> @@ -111,7 +111,7 @@ generate_unique_tap_name(TapNames) -> handle_call({domain_create, Conf}, _From, State) -> {Table} = State, DomainID = virtuerl_util:uuid4(), - Domain = maps:merge(#{id => DomainID, name => DomainID}, Conf), % TODO: save ipv4 addr as well + Domain = maps:merge(#{id => DomainID, name => DomainID, vcpu => 1, memory => 512}, Conf), % TODO: save ipv4 addr as well dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), @@ -182,24 +182,27 @@ handle_call({domain_update, #{id := DomainID, state := RunState}}, _From, {Table handle_call(domains_list, _From, State) -> {Table} = State, Domains = dets:match_object(Table, '_'), - {reply, [maps:merge(#{state => stopped, name => Id}, Domain) || {Id, Domain} <- Domains], State}; + {reply, [maps:merge(#{state => running, name => Id, vcpu => 1, memory => 512}, Domain) || {Id, Domain} <- Domains], State}; handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of [{_, #{mac_addr := MacAddr, ipv4_addr:=IP, tap_name := TapName} = Domain}] -> DomRet = Domain#{mac_addr := binary:encode_hex(MacAddr), ipv4_addr := virtuerl_net:format_ip_bitstring(IP), tap_name := iolist_to_binary(TapName)}, - {ok, maps:merge(#{name => DomainID}, DomRet)}; + {ok, maps:merge(#{state => running, name => DomainID, vcpu => 1, memory => 512}, DomRet)}; [] -> notfound end, {reply, Reply, State}; handle_call({domain_delete, #{id := DomainID}}, _From, State) -> {Table} = State, + ok = virtuerl_ipam:unassign(DomainID), Res = dets:delete(Table, DomainID), dets:sync(Table), io:format("terminating ~p~n", [DomainID]), - ok = supervisor:terminate_child(virtuerl_sup, DomainID), + supervisor:terminate_child(virtuerl_sup, DomainID), io:format("done terminating ~p~n", [DomainID]), - ok = supervisor:delete_child(virtuerl_sup, DomainID), + supervisor:delete_child(virtuerl_sup, DomainID), + DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), + file:del_dir_r(DomainHomePath), ok = gen_server:call(virtuerl_net, {net_update}), {reply, Res, State}. diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 01d9a5d..6031ad4 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -142,7 +142,7 @@ update_nftables(Domains) -> " chain postrouting {\n", " type nat hook postrouting priority -5; policy accept;\n", - " oifname != \"verlbr*\" iifname \"verlbr*\" masquerade\n", + " oifname != \"verlbr*\" iifname \"verlbr*\" masquerade\n", % TODO: we need to base it on IPs " }\n", "}\n" ], @@ -258,7 +258,7 @@ generate_unique_bridge_name(Ifnames) -> generate_unique_bridge_name(Ifnames) end. -to_vtap_map(MacAddr) -> +to_vtap_mac(MacAddr) -> <> = MacAddr, <>. @@ -274,7 +274,7 @@ sync_taps(Domains) -> TapsTarget = sets:from_list([iolist_to_binary(TapName) || {_, #{tap_name := TapName}} <- Domains]), % TODO: persist tap_name as binary io:format("Taps Target: ~p~n", [sets:to_list(TapsTarget)]), io:format("Taps Actual: ~p~n", [sets:to_list(TapsActual)]), - TapsMap = maps:from_list([{iolist_to_binary(Tap), {to_vtap_map(MacAddr), network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), + TapsMap = maps:from_list([{iolist_to_binary(Tap), {to_vtap_mac(MacAddr), network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index 9ce0f7f..3981c5a 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -39,22 +39,24 @@ callback_mode() -> init([ID]) -> {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), [{DomainId, #{mac_addr:=MacAddr, tap_name := TapName} = DomainRaw}] = dets:lookup(Table, ID), - Domain = maps:merge(#{user_data => ""}, DomainRaw), + Domain = maps:merge(#{user_data => "", vcpu => 1, memory => 512}, DomainRaw), DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId]), ok = filelib:ensure_path(DomainHomePath), RootVolumePath = filename:join(DomainHomePath, "root.qcow2"), case filelib:is_regular(RootVolumePath) of false -> -%% BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), - BaseImagePath = filename:join([virtuerl_mgt:home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"]), - exec:run(lists:flatten(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s", [filename:absname(BaseImagePath), RootVolumePath])), [sync]); + BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), +%% BaseImagePath = filename:join([virtuerl_mgt:home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"]), + exec:run(lists:flatten(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s 20G", [filename:absname(BaseImagePath), RootVolumePath])), [sync]); _ -> noop end, process_flag(trap_exit, true), ensure_cloud_config(Domain), file:delete(filename:join(DomainHomePath, "qmp.sock")), file:delete(filename:join(DomainHomePath, "serial.sock")), - Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc :1 -display none -serial none -m 512 -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off"]), % -serial unix:serial.sock,server=on,wait=off + file:delete(filename:join(DomainHomePath, "vnc.sock")), + #{vcpu := Vcpu, memory := Memory} = Domain, + Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc unix:vnc.sock -display none -serial none -smp ",integer_to_binary(Vcpu)," -m ",integer_to_binary(Memory)," -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off"]), % -serial unix:serial.sock,server=on,wait=off io:format("QEMU cmdline: ~s~n", [Cmd]), {ok, Pid, OsPid} = exec:run_link(Cmd, [{cd, DomainHomePath}]), State = #{table => Table, id => ID, domain => Domain, qemu_pid => {Pid, OsPid}, qmp_pid => undefined}, @@ -179,7 +181,7 @@ ensure_cloud_config(#{id := DomainID} = Domain) -> false -> create_cloud_config(Domain) end. -create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs, user_data := UserData}) -> +create_cloud_config(#{id := DomainID, name := DomainName, mac_addr := MacAddr, cidrs := Cidrs, user_data := UserData}) -> NetConf = [ "version: 2\n", "ethernets:\n", @@ -189,6 +191,8 @@ create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs, user_ " set-name: ens2\n", " dhcp4: false\n", " dhcp6: false\n", + " nameservers:\n", + " addresses: [8.8.8.8, 8.8.4.4]\n", " addresses:\n", [[ " - ", virtuerl_net:format_ip(IpAddr), "/", integer_to_binary(Prefixlen), "\n"] || {IpAddr, Prefixlen} <- Cidrs], " routes:\n", [[ @@ -198,7 +202,7 @@ create_cloud_config(#{id := DomainID, mac_addr := MacAddr, cidrs := Cidrs, user_ ], MetaData = [ "instance-id: ", DomainID, "\n", - "local-hostname: ", DomainID, "\n" + "local-hostname: ", DomainName, "\n" ], DomainBasePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), IsoBasePath = filename:join(DomainBasePath, "iso"), diff --git a/virtuerl/src/virtuerl_ui.erl b/virtuerl/src/virtuerl_ui.erl index ca2238f..3718022 100644 --- a/virtuerl/src/virtuerl_ui.erl +++ b/virtuerl/src/virtuerl_ui.erl @@ -35,7 +35,7 @@ -behaviour(wx_object). --record(state, {win, info_panel, info, domain_panel, domain_info, toolbar, domain_list_box, domains}). +-record(state, {win, info_panel, info, domain_panel, domain_info, toolbar, domain_list_box, domains, page, net_list_box}). start() -> wx_object:start_link(?MODULE, [], []). @@ -60,31 +60,7 @@ init([]) -> {Mx, My, _, _} = wxMiniFrame:getTextExtent(Frame, "M"), wxFrame:setClientSize(Frame, {60*Mx, 20*My}), - PlayIconDC = wxMemoryDC:new(), - PlayIcon = wxBitmap:new(30, 30, [{depth, 32}]), - wxBufferedDC:selectObject(PlayIconDC, PlayIcon), - wxMemoryDC:setBrush(PlayIconDC, ?wxGREEN_BRUSH), - wxMemoryDC:setPen(PlayIconDC, ?wxGREEN_PEN), - wxMemoryDC:drawPolygon(PlayIconDC, [{0,0},{30,15},{0,30}]), - wxMemoryDC:destroy(PlayIconDC), - PlayIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(PlayIcon))), - - StopIconDC = wxMemoryDC:new(), - StopIcon = wxBitmap:new(30, 30, [{depth, 32}]), - wxBufferedDC:selectObject(StopIconDC, StopIcon), - wxMemoryDC:setBrush(StopIconDC, ?wxRED_BRUSH), - wxMemoryDC:setPen(StopIconDC, ?wxRED_PEN), - wxMemoryDC:drawRectangle(StopIconDC, {0,0},{30,30}), - wxMemoryDC:destroy(StopIconDC), - StopIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(StopIcon))), - - Toolbar = wxFrame:createToolBar(Frame), - wxToolBar:addTool(Toolbar, 100, "test123", PlayIcon, PlayIconDisabled), - wxToolBar:enableTool(Toolbar, 100, false), - wxToolBar:addTool(Toolbar, 101, "test123", StopIcon, StopIconDisabled), - wxToolBar:enableTool(Toolbar, 101, false), - wxToolBar:realize(Toolbar), - wxToolBar:connect(Toolbar, command_menu_selected), + Toolbar = create_toolbar(Frame, 100), wxFrame:createStatusBar(Frame,[]), @@ -119,7 +95,7 @@ init([]) -> wxSizer:add(InfoSizer, InfoGrid, [{flag, ?wxEXPAND}, {proportion, 1}]), wxPanel:setSizer(Info, InfoSizer), - wxSplitterWindow:splitVertically(NetworkSplitter, ListBox, Info, [{sashPosition, 25 * Mx}]), + wxSplitterWindow:splitHorizontally(NetworkSplitter, ListBox, Info, [{sashPosition, 25 * Mx}]), % BEGIN Domains DomainPanel = wxPanel:new(Notebook, []), @@ -129,14 +105,16 @@ init([]) -> wxPanel:setSizer(DomainPanel, DomainsSizer), wxNotebook:addPage(Notebook, DomainPanel, "Domains"), + wxNotebook:connect(Notebook, command_notebook_page_changed), wxNotebook:setSelection(Notebook, 1), Domains = virtuerl_mgt:domains_list(), - ColumnNames = ["ID", "Name", "IPs"], - DomainsTuples = [{Id, Name, lists:join($,, [virtuerl_net:format_ip(Ip) || {Ip, _Prefixlen} <- Cidrs])} || #{id := Id, name := Name, cidrs := Cidrs} <- Domains], - DomainsIds = [Id || {Id, _Name, _} <- DomainsTuples], + ColumnNames = ["ID", "Name", "IPs", "CPU", "RAM"], + ColumnAlignment = [?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_RIGHT, ?wxLIST_FORMAT_RIGHT], + DomainsTuples = [{Id, Name, lists:join($,, [virtuerl_net:format_ip(Ip) || {Ip, _Prefixlen} <- Cidrs]), integer_to_binary(Vcpu), [integer_to_binary(Memory), $M]} || #{id := Id, name := Name, cidrs := Cidrs, vcpu := Vcpu, memory := Memory} <- Domains], + DomainsIds = [Id || {Id, _Name, _, _, _} <- DomainsTuples], DomainListBox = wxListCtrl:new(DomainSplitter, [{style, ?wxLC_REPORT}]), - lists:foreach(fun ({Idx, Name}) -> wxListCtrl:insertColumn(DomainListBox, Idx, Name) end, lists:enumerate(0, ColumnNames)), + lists:foreach(fun ({Idx, Name}) -> wxListCtrl:insertColumn(DomainListBox, Idx, Name, [{format, lists:nth(Idx + 1, ColumnAlignment)}]) end, lists:enumerate(0, ColumnNames)), lists:foreach(fun (Idx) -> Item = wxListItem:new(), wxListItem:setId(Item, Idx), @@ -165,7 +143,7 @@ init([]) -> wxSizer:add(DomainButtonsSizer, DomainDelBtn), wxSizer:add(DomainInfoSizer, DomainButtonsSizer, [{flag, ?wxALIGN_RIGHT}]), - wxSplitterWindow:splitVertically(DomainSplitter, DomainListBox, DomainInfo, [{sashPosition, 25 * Mx}]), + wxSplitterWindow:splitHorizontally(DomainSplitter, DomainListBox, DomainInfo, [{sashPosition, 25 * Mx}]), % END Domains ok = wxFrame:setStatusText(Frame, "Hello World!",[]), @@ -174,8 +152,65 @@ init([]) -> wxWindow:raise(Frame), wxWindow:setFocus(Frame), wxWindow:layout(Frame), - {Frame, #state{win=Frame, info_panel = Info, info=InfoGrid, domain_panel = DomainInfo, domain_info=DomainInfoGrid, domain_list_box=DomainListBox, toolbar=Toolbar, domains = DomainsIds}}. + {Frame, #state{toolbar = Toolbar, page = 1, win=Frame, net_list_box = ListBox, info_panel = Info, info=InfoGrid, domain_panel = DomainInfo, domain_info=DomainInfoGrid, domain_list_box=DomainListBox, domains = DomainsIds}}. + +create_toolbar(Frame, BaseNum) -> + PlayIconDC = wxMemoryDC:new(), + PlayIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(PlayIconDC, PlayIcon), + wxMemoryDC:setBrush(PlayIconDC, ?wxGREEN_BRUSH), + wxMemoryDC:setPen(PlayIconDC, ?wxGREEN_PEN), + wxMemoryDC:drawPolygon(PlayIconDC, [{0,0},{30,15},{0,30}]), + wxMemoryDC:destroy(PlayIconDC), + PlayIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(PlayIcon))), + + StopIconDC = wxMemoryDC:new(), + StopIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(StopIconDC, StopIcon), + wxMemoryDC:setBrush(StopIconDC, ?wxRED_BRUSH), + wxMemoryDC:setPen(StopIconDC, ?wxRED_PEN), + wxMemoryDC:drawRectangle(StopIconDC, {0,0},{30,30}), + wxMemoryDC:destroy(StopIconDC), + StopIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(StopIcon))), + DelIconDC = wxMemoryDC:new(), + DelIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(DelIconDC, DelIcon), + wxMemoryDC:setBrush(DelIconDC, ?wxBLUE_BRUSH), + wxMemoryDC:setPen(DelIconDC, ?wxBLACK_PEN), + wxMemoryDC:drawRectangle(DelIconDC, {3,10},{24,20}), + wxMemoryDC:drawRectangle(DelIconDC, {0,5},{30,5}), + wxMemoryDC:drawRectangle(DelIconDC, {10,0},{10,5}), + wxMemoryDC:setBrush(DelIconDC, ?wxWHITE_BRUSH), + wxMemoryDC:setPen(DelIconDC, ?wxWHITE_PEN), + wxMemoryDC:drawLine(DelIconDC, {9,14}, {9,26}), + wxMemoryDC:drawLine(DelIconDC, {15,14}, {15,26}), + wxMemoryDC:drawLine(DelIconDC, {21,14}, {21,26}), + wxMemoryDC:destroy(DelIconDC), + DelIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(DelIcon))), + + AddIconDC = wxMemoryDC:new(), + AddIcon = wxBitmap:new(30, 30, [{depth, 32}]), + wxBufferedDC:selectObject(AddIconDC, AddIcon), + wxMemoryDC:setBrush(AddIconDC, ?wxGREEN_BRUSH), + wxMemoryDC:setPen(AddIconDC, ?wxGREEN_PEN), + wxMemoryDC:drawRectangle(AddIconDC, {0,12},{30,6}), + wxMemoryDC:drawRectangle(AddIconDC, {12,0},{6,30}), + wxMemoryDC:destroy(AddIconDC), + AddIconDisabled = wxBitmap:new(wxImage:convertToGreyscale(wxBitmap:convertToImage(AddIcon))), + + Toolbar = wxFrame:createToolBar(Frame), + wxToolBar:addTool(Toolbar, BaseNum + 0, "test123", PlayIcon, PlayIconDisabled), + wxToolBar:enableTool(Toolbar, BaseNum + 0, false), + wxToolBar:addTool(Toolbar, BaseNum + 1, "test123", StopIcon, StopIconDisabled), + wxToolBar:enableTool(Toolbar, BaseNum + 1, false), + wxToolBar:addTool(Toolbar, BaseNum + 2, "test123", DelIcon, DelIconDisabled), + wxToolBar:enableTool(Toolbar, BaseNum + 2, false), + wxToolBar:addTool(Toolbar, BaseNum + 3, "test123", AddIcon, AddIconDisabled), + wxToolBar:enableTool(Toolbar, BaseNum + 3, true), + wxToolBar:realize(Toolbar), + wxToolBar:connect(Toolbar, command_menu_selected), + Toolbar. %% Handled as in normal gen_server callbacks handle_info({domain_out, _Id, Text}, #state{domain_panel = DomainPanel} = State) -> @@ -193,6 +228,9 @@ handle_call(Msg, _From, State) -> {reply,ok,State}. %% Async Events are handled in handle_event as in handle_info +handle_event(#wx{event = #wxBookCtrl{nSel = Index}}, State) -> + io:format("TAB: ~p~n", [Index]), + {noreply, State#state{page = Index}}; handle_event(#wx{id = 42, event = #wxCommand{type = command_listbox_selected, cmdString = Choice}}, State = #state{info_panel = Panel, info=Info, domains = DomainIds}) -> @@ -221,6 +259,7 @@ handle_event(#wx{event = #wxList{type = command_list_item_selected, wxToolBar:enableTool(Toolbar, 100, true), wxToolBar:enableTool(Toolbar, 101, false) end, + wxToolBar:enableTool(Toolbar, 102, true), wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, "ID"), {0, 0}), wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, DomainId), {0, 1}), wxGridBagSizer:add(DomainInfo, wxStaticText:new(DomainPanel, -1, "Network ID"), {1, 0}), @@ -238,22 +277,22 @@ handle_event(#wx{event = #wxList{type = command_list_item_selected, %% wxGridBagSizer:add(DomainInfo, SerialOut, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), %% WebView = wxWebView:new(DomainPanel, 999, [{url, "http://0.0.0.0:9000/noVNC-1.4.0/vnc.html?port=5700&?path=&resize=scale&autoconnect=true"}]), %% wxGridBagSizer:add(DomainInfo, WebView, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), - VncWindow = virtuerl_vnc:start(DomainPanel), - wxGridBagSizer:add(DomainInfo, VncWindow, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), + VncWindow = virtuerl_vnc:start(DomainPanel, DomainId), + wxGridBagSizer:add(DomainInfo, VncWindow, {0, 2}, [{span, {3, 1}}, {flag, ?wxEXPAND}]), - wxGridBagSizer:addGrowableRow(DomainInfo, 3), + wxGridBagSizer:addGrowableRow(DomainInfo, 2), UserData = maps:get(user_data, Domain, ""), UserDataCtrl = wxStyledTextCtrl:new(DomainPanel), wxStyledTextCtrl:setScrollWidth(UserDataCtrl, wxStyledTextCtrl:textWidth(UserDataCtrl, wxStyledTextCtrl:getStyleAt(UserDataCtrl, 0), UserData)), wxStyledTextCtrl:setText(UserDataCtrl, list_to_binary(UserData)), wxStyledTextCtrl:setReadOnly(UserDataCtrl, true), - LastRowIndex = 4, + LastRowIndex = 3, %% Msg = wxNotificationMessage:new(lists:flatten(io_lib:format("LastRowIndex: ~p~n", [LastRowIndex]))), %% wxNotificationMessage:show(Msg), - wxGridBagSizer:add(DomainInfo, UserDataCtrl, {LastRowIndex, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), + wxGridBagSizer:add(DomainInfo, UserDataCtrl, {LastRowIndex, 0}, [{span, {1, 3}}, {flag, ?wxEXPAND}]), wxGridBagSizer:addGrowableRow(DomainInfo, LastRowIndex), - wxGridBagSizer:addGrowableCol(DomainInfo, 1), + wxGridBagSizer:addGrowableCol(DomainInfo, 2), wxPanel:layout(DomainPanel), io:format("dblclick ~p (~p)~n", [DomainId, Domain]), {noreply, State}; @@ -263,7 +302,7 @@ handle_event(#wx{id = 4044, event = #wxCommand{type = command_button_clicked}}, {ok, Domain} = virtuerl_mgt:domain_get(#{id => DomainId}), create_domain_dialog(Domain), {noreply, State}; -handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), @@ -273,7 +312,7 @@ handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu wxToolBar:enableTool(Toolbar, 101, true), ok = virtuerl_mgt:domain_start(Choice), {noreply, State}; -handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), @@ -283,6 +322,29 @@ handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu wxToolBar:enableTool(Toolbar, 101, false), ok = virtuerl_mgt:domain_stop(Choice), {noreply, State}; +handle_event(#wx{id = 102, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> + io:format("~p~n", [Event]), + SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), + DomainId = lists:nth(SelectedItem + 1, DomainIds), + Choice = DomainId, + io:format("~p~n", [Choice]), +%% wxToolBar:enableTool(Toolbar, 100, true), +%% wxToolBar:enableTool(Toolbar, 101, false), +%% ok = virtuerl_mgt:domain_stop(Choice), + virtuerl_mgt:domain_delete(#{id => DomainId}), + {noreply, State}; +handle_event(#wx{id = 103, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> + create_domain_dialog(#{network_id => "", name=> "", user_data => "", vcpu => 2, memory => 1024}), + {noreply, State}; +%% BEGIN: Network Toolbar +handle_event(#wx{id = 102, event = #wxCommand{type = command_menu_selected}}, #state{page = 0, net_list_box = ListBox} = State) -> + NetId = wxListBox:getStringSelection(ListBox), + virtuerl_ipam:ipam_delete_net(NetId), + {noreply, State}; +handle_event(#wx{id = 103, event = #wxCommand{type = command_menu_selected}}, #state{page = 0} = State) -> + create_network_dialog(), + {noreply, State}; +%% END: Network Toolbar handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) -> io:format("~p Closing window ~n",[self()]), ok = wxFrame:setStatusText(Frame, "Closing...",[]), @@ -292,7 +354,10 @@ handle_event(#wx{id = ?wxID_EXIT, event = #wxCommand{type = command_menu_selecte io:format("~p Quitting window ~n",[self()]), ok = wxFrame:setStatusText(Frame, "Closing...",[]), wxWindow:destroy(Frame), - {stop, normal, State}. + {stop, normal, State}; +handle_event(Event, State) -> + io:format("Unknown Event: ~p~n", [Event]), + {noreply, State}. code_change(_, _, State) -> {stop, not_yet_implemented, State}. @@ -300,16 +365,46 @@ code_change(_, _, State) -> terminate(_Reason, _State) -> ok. -create_domain_dialog(#{network_id := NetworkId, user_data := UserData} = Domain) -> +create_network_dialog() -> + Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Network", [{size, {1000, 500}}]), + DialogSizer = wxBoxSizer:new(?wxVERTICAL), + DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "CIDR")), + CidrCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY), + wxSizer:add(DialogGridSizer, CidrCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), + wxSizer:add(DialogSizer, DialogGridSizer), + ButtonSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL), + wxSizer:add(DialogSizer, ButtonSizer), + wxPanel:setSizer(Dialog, DialogSizer), +%% wxWindow:layout(DialogSizer), + + case wxDialog:showModal(Dialog) of + ?wxID_OK -> + NetDef = virtuerl_net:parse_cidr(wxTextCtrl:getValue(CidrCtrl)), + {ok, NetId} = virtuerl_ipam:ipam_create_net([NetDef]); + _ -> ok + end, + wxDialog:destroy(Dialog). + +create_domain_dialog(#{network_id := NetworkId, name:= DomainName, user_data := UserData, vcpu := Vcpu, memory := Memory} = Domain) -> {ok, Nets} = virtuerl_ipam:ipam_list_nets(), Choices = maps:keys(Nets), Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Domain", [{size, {1000, 500}}]), DialogSizer = wxBoxSizer:new(?wxVERTICAL), DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Name")), + NameCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, DomainName}]), + wxSizer:add(DialogGridSizer, NameCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Network")), NetworkChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, Choices}]), wxChoice:setStringSelection(NetworkChoice, NetworkId), wxSizer:add(DialogGridSizer, NetworkChoice), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "CPU")), + VcpuCtrl = wxSpinCtrl:new(Dialog, [{min, 1}, {max, 256}, {initial, Vcpu}]), + wxSizer:add(DialogGridSizer, VcpuCtrl), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Memory")), + MemoryCtrl = wxSpinCtrl:new(Dialog, [{min, 128}, {max, 131072}, {initial, Memory}]), + wxSizer:add(DialogGridSizer, MemoryCtrl), wxSizer:add(DialogSizer, DialogGridSizer), UserDataCtrl = wxStyledTextCtrl:new(Dialog), wxStyledTextCtrl:setLexer(UserDataCtrl, ?wxSTC_LEX_YAML), @@ -322,7 +417,13 @@ create_domain_dialog(#{network_id := NetworkId, user_data := UserData} = Domain) case wxDialog:showModal(Dialog) of ?wxID_OK -> io:format("true ~p~n", [wxChoice:getStringSelection(NetworkChoice)]), - virtuerl_mgt:domain_create(#{network_id => list_to_binary(wxChoice:getStringSelection(NetworkChoice)), user_data => wxStyledTextCtrl:getText(UserDataCtrl)}); + virtuerl_mgt:domain_create(#{ + name => wxTextCtrl:getValue(NameCtrl), + network_id => list_to_binary(wxChoice:getStringSelection(NetworkChoice)), + user_data => wxStyledTextCtrl:getText(UserDataCtrl), + vcpu => wxSpinCtrl:getValue(VcpuCtrl), + memory => wxSpinCtrl:getValue(MemoryCtrl) + }); _ -> ok end, wxDialog:destroy(Dialog); diff --git a/virtuerl/src/virtuerl_vnc.erl b/virtuerl/src/virtuerl_vnc.erl index 02caf79..5dc343d 100644 --- a/virtuerl/src/virtuerl_vnc.erl +++ b/virtuerl/src/virtuerl_vnc.erl @@ -33,7 +33,7 @@ -export([ init/1, handle_info/2, handle_event/2, code_change/3, terminate/2]). --export([start/1]). +-export([start/2]). -behaviour(wx_object). @@ -48,67 +48,14 @@ -define(vncMSG_TYPE_PointerEvent, 5). -define(vncENCODING_RAW, 0). --record(state, {win, socket, panel, tex_id, vnc_conf}). +-record(state, {win, socket, panel, tex_id, vnc_conf, parent}). -record(vnc_conf, {width, height}). -start(Parent) -> - wx_object:start_link(?MODULE, [Parent], []). +start(Parent, DomainId) -> + wx_object:start_link(?MODULE, [Parent, DomainId], []). %% Init is called in the new process. -init([Parent]) -> - {ok, Socket} = gen_tcp:connect("localhost", 5901, [{active, true}, binary]), - receive - {tcp, Socket, <<"RFB ", Major:3/binary, ".", Minor:3/binary, "\n">>} -> - io:format("Major: ~s / Minor: ~s~n", [Major, Minor]), - ok - after 2000 -> - timeout - end, - - ok = gen_tcp:send(Socket, <<"RFB 003.008\n">>), - receive - {tcp, Socket, <>} -> - io:format("AuthType: ~p~n", [AuthType]), - case AuthType of - ?vncINVALID -> {error, auth_invalid}; - ?vncNONE -> ok; - ?vncVNC_AUTH -> {error, auth_not_supported}; - _ -> io:format("Unknown auth: ~p~n", [AuthType]) - end - after 2000 -> - {error, timeout} - end, - - ok = gen_tcp:send(Socket, <>), - receive - {tcp, Socket, <>} -> - io:format("Security result: ~B~n", [SecurityResult]), - case SecurityResult of - ?vncOK -> ok; - ?vncFAILED -> error - end - after 2000 -> - {error, timeout} - end, - - ok = gen_tcp:send(Socket, <<1>>), - VncConf = receive - {tcp, Socket, <>} -> - io:format("~s: ~Bx~B~n~B/~B (BE: ~B, TC: ~B)~nR:(X>>~B)&~B G:(X>>~B)&~B B:(X>>~B)&~B~n", [Name, Width, Height, Depth, BitsPerPixel, BigEndianFlag, TrueColorFlag, RedShift, RedMax, GreenShift, GreenMax, BlueShift, BlueMax]), - #vnc_conf{width = Width, height = Height} - after 2000 -> - {error, timeout} - end, - #vnc_conf{width = VncWidth, height = VncHeight} = VncConf, -%% #vnc_conf{width = Width, height = Height} = #vnc_conf{width = 800, height = 600}, - inet:setopts(Socket, [{active, once}]), - ok = gen_tcp:send(Socket, <>), - +init([Parent, DomainId]) -> {Mx, My, _, _} = wxWindow:getTextExtent(Parent, "M"), %% wxFrame:setClientSize(Frame, {60*Mx, 20*My}), Panel = wxGLCanvas:new(Parent, [{attribList, [?WX_GL_RGBA,?WX_GL_DOUBLEBUFFER,0]}]), @@ -120,7 +67,17 @@ init([Parent]) -> wxGLCanvas:setCurrent(Panel, Context), -gl:enable(?GL_TEXTURE_2D), + VncProxy = virtuerl_vnc_proxy:start(DomainId), + {VncWidth, VncHeight} = receive + {conf, TVncWidth, TVncHeight} -> {TVncWidth, TVncHeight} + after 1000 -> + io:format("the foock?~n"), + {700, 400} + end, + + VncProxy ! {framebuffer_update_request, 0, 0, 0, VncWidth, VncHeight}, + + gl:enable(?GL_TEXTURE_2D), [TexId] = gl:genTextures(1), io:format("TEXTURE ID: ~p~n", [TexId]), gl:bindTexture(?GL_TEXTURE_2D, TexId), @@ -130,57 +87,29 @@ gl:enable(?GL_TEXTURE_2D), io:format("ERROR: ~p~n", [glu:errorString(Err)]), wxGLCanvas:connect(Panel, erase_background, [{callback, fun(_,_) -> ok end}]), wxGLCanvas:connect(Panel, paint), - {Panel, #state{socket=Socket, panel = Panel, tex_id = TexId, vnc_conf = VncConf}}. - -read_rects(0, _, Socket) -> - []; -read_rects(NumRects, Data, Socket) -> - case Data of - <> -> - case Encoding of - ?vncENCODING_RAW -> - NumBytes = Width * Height * 4, - case NumBytes > byte_size(Rest) of - true -> - BytesToFetch = NumBytes - byte_size(Rest) + (NumRects - 1) * 12, - {ok, MoreData} = gen_tcp:recv(Socket, BytesToFetch), - read_rects(NumRects, <>, Socket); - false -> - <> = Rest, - Rect = {X, Y, Width, Height, PixelBytes}, - Rects = read_rects(NumRects - 1, ActualRest, Socket), - [Rect | Rects] - end; - _ -> io:format("Unsupported encoding ~p~n", [Encoding]) - end; - _ -> - {ok, MoreData} = gen_tcp:recv(Socket, 12 - byte_size(Data) + (NumRects - 1) * 12), - read_rects(NumRects, <>, Socket) - end. + {Panel, #state{socket=VncProxy, parent = Parent, panel = Panel, tex_id = TexId, vnc_conf = {VncWidth, VncHeight}}}. %% Handled as in normal gen_server callbacks -handle_info({tcp, Socket, <>}, #state{panel = Panel, tex_id = TexId, vnc_conf = #vnc_conf{width = Width, height = Height}} = State) -> - {TimeRects, Rects} = timer:tc(fun() -> read_rects(NumRects, Rest, Socket) end), - {TimeRes, _} = timer:tc(fun() -> +handle_info({framebuffer_update, Rects}, #state{socket = Proxy, panel = Panel, tex_id = TexId, vnc_conf = {VncWidth, VncHeight}} = State) -> +%% io:format("got framebuffer_update~n"), wx:batch(fun() -> gl:bindTexture(?GL_TEXTURE_2D, TexId), [gl:texSubImage2D(?GL_TEXTURE_2D, 0, X, Y, Width, Height, ?GL_BGRA, ?GL_UNSIGNED_BYTE, Data) || {X, Y, Width, Height, Data} <- Rects] end), - gl:flush() - end), + gl:flush(), wxPanel:refresh(Panel, [{eraseBackground, false}]), %% io:format("Writing rects took ~p/~p~n", [TimeRects, TimeRes]), - inet:setopts(Socket, [{active, once}]), - ok = gen_tcp:send(Socket, <>), + + Proxy ! {framebuffer_update_request, 1, 0, 0, VncWidth, VncHeight}, {noreply, State}; handle_info(Msg, State) -> io:format("Got Info ~p~n",[Msg]), {noreply,State}. -handle_event(#wx{event=#wxPaint{type = paint}, obj = _Obj}, State = #state{win=Frame, panel=Panel, tex_id = TexId, vnc_conf = #vnc_conf{width = Width, height = Height}}) -> - {W, H} = wxGLCanvas:getSize(_Obj), +handle_event(#wx{event=#wxPaint{type = paint}, obj = _Obj}, State = #state{parent = Parent, win=Frame, panel=Panel, tex_id = TexId, vnc_conf = {Width, Height}}) -> + {W, H} = wxGLCanvas:getSize(Panel), Wscale = W / Width, Hscale = H / Height, {Scale, Xt, Yt} = case Wscale > Hscale of @@ -213,7 +142,7 @@ handle_event(#wx{event=#wxPaint{type = paint}, obj = _Obj}, State = #state{win=F gl:'end'(), gl:flush(), - wxGLCanvas:swapBuffers(_Obj), + wxGLCanvas:swapBuffers(Panel), {noreply, State}; handle_event(#wx{event=#wxKey{type = Type, keyCode = KeyCode, rawCode = Key}} = Event, State = #state{win=Frame, panel=Panel, socket = Socket}) -> io:format("Event ~p~n", [Event]), @@ -221,7 +150,7 @@ handle_event(#wx{event=#wxKey{type = Type, keyCode = KeyCode, rawCode = Key}} = key_down -> 1; key_up -> 0 end, - ok = gen_tcp:send(Socket, <>), + Socket ! {key_event, DownFlag, Key}, {noreply, State}; handle_event(#wx{id = ?wxID_EXIT, event = #wxCommand{type = command_menu_selected}}, State = #state{win=Frame}) -> io:format("~p Quitting window ~n",[self()]), diff --git a/virtuerl/src/virtuerl_vnc_proxy.erl b/virtuerl/src/virtuerl_vnc_proxy.erl new file mode 100644 index 0000000..cec75b5 --- /dev/null +++ b/virtuerl/src/virtuerl_vnc_proxy.erl @@ -0,0 +1,143 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_vnc_proxy). + +-export([start/1]). + +-define(SERVER, ?MODULE). +-define(APPLICATION, virtuerl). + +-define(vncINVALID, 0). +-define(vncNONE, 1). +-define(vncVNC_AUTH, 2). +-define(vncOK, 0). +-define(vncFAILED, 1). +-define(vncMSG_TYPE_FramebufferUpdate, 0). +-define(vncMSG_TYPE_FramebufferUpdateRequest, 3). +-define(vncMSG_TYPE_KeyEvent, 4). +-define(vncMSG_TYPE_PointerEvent, 5). +-define(vncENCODING_RAW, 0). + +-record(state, {win, socket, panel, tex_id, vnc_conf}). +-record(vnc_conf, {width, height}). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +start(DomainId) -> + VncSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId, "vnc.sock"]), + Self = self(), + spawn(fun() -> init(VncSocketPath, Self) end). + +init(VncSocketPath, Sender) -> + {ok, Socket} = gen_tcp:connect({local, VncSocketPath}, 0, [{active, true}, binary, local]), + receive + {tcp, Socket, <<"RFB ", Major:3/binary, ".", Minor:3/binary, "\n">>} -> + io:format("Major: ~s / Minor: ~s~n", [Major, Minor]), + ok + after 2000 -> + timeout + end, + + ok = gen_tcp:send(Socket, <<"RFB 003.008\n">>), + receive + {tcp, Socket, <>} -> + % TODO: AuthTypes is a list + io:format("AuthType: ~p~n", [AuthType]), + case AuthType of + ?vncINVALID -> {error, auth_invalid}; + ?vncNONE -> ok; + ?vncVNC_AUTH -> {error, auth_not_supported}; + _ -> io:format("Unknown auth: ~p~n", [AuthType]) + end + after 2000 -> + {error, timeout} + end, + + ok = gen_tcp:send(Socket, <>), + receive + {tcp, Socket, <>} -> + io:format("Security result: ~B~n", [SecurityResult]), + case SecurityResult of + ?vncOK -> ok; + ?vncFAILED -> error + end + after 2000 -> + {error, timeout} + end, + + ok = gen_tcp:send(Socket, <<1>>), + VncConf = receive + {tcp, Socket, <>} -> + io:format("~s: ~Bx~B~n~B/~B (BE: ~B, TC: ~B)~nR:(X>>~B)&~B G:(X>>~B)&~B B:(X>>~B)&~B~n", [Name, Width, Height, Depth, BitsPerPixel, BigEndianFlag, TrueColorFlag, RedShift, RedMax, GreenShift, GreenMax, BlueShift, BlueMax]), + #vnc_conf{width = Width, height = Height} + after 2000 -> + {error, timeout} + end, + #vnc_conf{width = VncWidth, height = VncHeight} = VncConf, + inet:setopts(Socket, [{active, once}]), + + Sender ! {conf, VncWidth, VncHeight}, + + monitor(process, Sender), + loop(Socket, Sender). + +loop(Socket, Sender) -> + receive + {tcp, Socket, <>} -> + {TimeRects, Rects} = timer:tc(fun() -> read_rects(NumRects, Rest, Socket) end), + Sender ! {framebuffer_update, Rects}, + inet:setopts(Socket, [{active, once}]), + loop(Socket, Sender); + {tcp, Socket,_Data} -> + io:format("Got data: ~p~n", [_Data]), + inet:setopts(Socket, [{active, once}]), + loop(Socket, Sender); + {framebuffer_update_request, Incremental, X, Y, Width, Height} -> + ok = gen_tcp:send(Socket, <>), + loop(Socket, Sender); + {key_event, DownFlag, Key} -> + ok = gen_tcp:send(Socket, <>), + loop(Socket, Sender); + {'DOWN', Ref, process, Pid, Reason} -> + io:format("Terminating because: ~p (~p)~n", [Reason, Pid]); + _Message -> + io:format("Got message: ~p~n", [_Message]), + loop(Socket, Sender) +end. + +read_rects(0, _Data, _Socket) -> + []; +read_rects(NumRects, Data, Socket) -> + case Data of + <> -> + case Encoding of + ?vncENCODING_RAW -> + NumBytes = Width * Height * 4, + case NumBytes > byte_size(Rest) of + true -> + BytesToFetch = NumBytes - byte_size(Rest) + (NumRects - 1) * 12, + {ok, MoreData} = gen_tcp:recv(Socket, BytesToFetch), + read_rects(NumRects, <>, Socket); + false -> + <> = Rest, + Rect = {X, Y, Width, Height, PixelBytes}, + Rects = read_rects(NumRects - 1, ActualRest, Socket), + [Rect | Rects] + end; + _ -> io:format("Unsupported encoding ~p~n", [Encoding]) + end; + _ -> + {ok, MoreData} = gen_tcp:recv(Socket, 12 - byte_size(Data) + (NumRects - 1) * 12), + read_rects(NumRects, <>, Socket) + end. From 1d483e6c41fc435265c768e4b3815a9232b04c98 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 8 Mar 2024 16:44:16 +0100 Subject: [PATCH 36/51] virtuerl: first working version with remote control --- virtuerl/README.md | 15 ++++++ virtuerl/rebar.config | 2 +- virtuerl/src/virtuerl_mgt.erl | 2 +- virtuerl/src/virtuerl_qemu.erl | 2 +- virtuerl/src/virtuerl_ui.erl | 76 +++++++++++++++-------------- virtuerl/src/virtuerl_util.erl | 9 +++- virtuerl/src/virtuerl_vnc.erl | 10 ++-- virtuerl/src/virtuerl_vnc_proxy.erl | 6 +-- 8 files changed, 73 insertions(+), 49 deletions(-) diff --git a/virtuerl/README.md b/virtuerl/README.md index 7d35a3f..91edc5e 100644 --- a/virtuerl/README.md +++ b/virtuerl/README.md @@ -7,3 +7,18 @@ Build ----- $ rebar3 compile + + +## Running + +On the server + +```sh +sudo -s ./erts-13.1.5/bin/erl -mode embedded -boot releases/0.7.0+build.61.ref8fc0b7e/start -config releases/0.7.0+build.61.ref8fc0b7e/sys.config -proto_dist inet6_tcp -name verbit@verbit.in-berlin.de -setcookie abcdef +``` + +Locally +```sh +rebar3 compile +erl -name moi -proto_dist inet6_tcp -setcookie abcdef -pa _build/default/lib/*/ebin -hidden +``` diff --git a/virtuerl/rebar.config b/virtuerl/rebar.config index c3f9abc..6596040 100644 --- a/virtuerl/rebar.config +++ b/virtuerl/rebar.config @@ -9,7 +9,7 @@ ]}. {relx, [ - {release, {virtuerl, git}, [virtuerl, {khepri, load}, {mnesia, load}]}, + {release, {virtuerl, git}, [virtuerl, {khepri, load}, {mnesia, load}, erts]}, {mode, prod} ]}. diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index 31b4d4f..c58b84b 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -68,7 +68,7 @@ handle_continue(setup_base, State) -> false -> TempImagePath = "/tmp/virtuerl/debian-12-genericcloud-amd64-20230910-1499.qcow2", ok = filelib:ensure_dir(TempImagePath), - httpc:request(get, "https://cloud.debian.org/images/cloud/bookworm/20230910-1499/debian-12-genericcloud-arm64-20230910-1499.qcow2", [], + {ok, _} = httpc:request(get, {"https://cloud.debian.org/images/cloud/bookworm/20230910-1499/debian-12-genericcloud-amd64-20230910-1499.qcow2", []}, [], [{stream, TempImagePath}]), file:rename(TempImagePath, BaseImagePath) end, diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index 3981c5a..b6ebc47 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -214,7 +214,7 @@ create_cloud_config(#{id := DomainID, name := DomainName, mac_addr := MacAddr, c UserDataPath = filename:join(IsoBasePath, "user-data"), ok = file:write_file(UserDataPath, UserData), IsoCmd = ["genisoimage -output ", filename:join(DomainBasePath, "cloud_config.iso"), " -volid cidata -joliet -rock ", UserDataPath, " ", MetaDataPath, " ", NetConfPath], - os:cmd(binary_to_list(iolist_to_binary(IsoCmd))), + ok = virtuerl_util:cmd(binary_to_list(iolist_to_binary(IsoCmd))), ok = file:del_dir_r(IsoBasePath), ok. diff --git a/virtuerl/src/virtuerl_ui.erl b/virtuerl/src/virtuerl_ui.erl index 3718022..5c92ed7 100644 --- a/virtuerl/src/virtuerl_ui.erl +++ b/virtuerl/src/virtuerl_ui.erl @@ -29,20 +29,22 @@ -module(virtuerl_ui). -include_lib("wx/include/wx.hrl"). --export([start/0, +-export([start/0, start/1, init/1, handle_info/2, handle_event/2, handle_call/3, code_change/3, terminate/2]). -behaviour(wx_object). --record(state, {win, info_panel, info, domain_panel, domain_info, toolbar, domain_list_box, domains, page, net_list_box}). +-record(state, {win, info_panel, info, domain_panel, domain_info, toolbar, domain_list_box, domains, page, net_list_box, node}). start() -> - wx_object:start_link(?MODULE, [], []). + start(node()). +start(Node) -> + wx_object:start_link(?MODULE, [Node], []). %% Init is called in the new process. -init([]) -> - virtuerl_pubsub:subscribe(), +init([Node]) -> +%% virtuerl_pubsub:subscribe(), wx:new(), Frame = wxFrame:new(wx:null(), @@ -84,7 +86,7 @@ init([]) -> wxNotebook:addPage(Notebook, NetworkPanel, "Networks"), - {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + {ok, Nets} = erpc:call(Node, virtuerl_ipam, ipam_list_nets, []), Choices = maps:keys(Nets), ListBox = wxListBox:new(NetworkSplitter, 42, [{choices, Choices}]), wxListBox:connect(ListBox, command_listbox_selected), % command_listbox_doubleclicked @@ -108,7 +110,7 @@ init([]) -> wxNotebook:connect(Notebook, command_notebook_page_changed), wxNotebook:setSelection(Notebook, 1), - Domains = virtuerl_mgt:domains_list(), + Domains = erpc:call(Node, virtuerl_mgt, domains_list, []), ColumnNames = ["ID", "Name", "IPs", "CPU", "RAM"], ColumnAlignment = [?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_LEFT, ?wxLIST_FORMAT_RIGHT, ?wxLIST_FORMAT_RIGHT], DomainsTuples = [{Id, Name, lists:join($,, [virtuerl_net:format_ip(Ip) || {Ip, _Prefixlen} <- Cidrs]), integer_to_binary(Vcpu), [integer_to_binary(Memory), $M]} || #{id := Id, name := Name, cidrs := Cidrs, vcpu := Vcpu, memory := Memory} <- Domains], @@ -152,7 +154,7 @@ init([]) -> wxWindow:raise(Frame), wxWindow:setFocus(Frame), wxWindow:layout(Frame), - {Frame, #state{toolbar = Toolbar, page = 1, win=Frame, net_list_box = ListBox, info_panel = Info, info=InfoGrid, domain_panel = DomainInfo, domain_info=DomainInfoGrid, domain_list_box=DomainListBox, domains = DomainsIds}}. + {Frame, #state{node = Node, toolbar = Toolbar, page = 1, win=Frame, net_list_box = ListBox, info_panel = Info, info=InfoGrid, domain_panel = DomainInfo, domain_info=DomainInfoGrid, domain_list_box=DomainListBox, domains = DomainsIds}}. create_toolbar(Frame, BaseNum) -> PlayIconDC = wxMemoryDC:new(), @@ -233,8 +235,8 @@ handle_event(#wx{event = #wxBookCtrl{nSel = Index}}, State) -> {noreply, State#state{page = Index}}; handle_event(#wx{id = 42, event = #wxCommand{type = command_listbox_selected, cmdString = Choice}}, - State = #state{info_panel = Panel, info=Info, domains = DomainIds}) -> - {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + State = #state{info_panel = Panel, info=Info, domains = DomainIds, node = Node}) -> + {ok, Nets} = erpc:call(Node, virtuerl_ipam, ipam_list_nets, []), Net = maps:get(list_to_binary(Choice), Nets), #{cidr4 := #{address := Address, prefixlen := Prefixlen}} = Net, wxFlexGridSizer:clear(Info, [{delete_windows, true}]), @@ -244,8 +246,8 @@ handle_event(#wx{id = 42, event = #wxCommand{type = command_listbox_selected, {noreply, State}; handle_event(#wx{event = #wxList{type = command_list_item_selected, itemIndex = ItemIndex}}, - State = #state{domain_panel = DomainPanel, domain_info = DomainInfo, toolbar=Toolbar, domains = DomainIds}) -> - Domains = maps:from_list([{Id, Domain} || Domain = #{id := Id} <- virtuerl_mgt:domains_list()]), + State = #state{domain_panel = DomainPanel, domain_info = DomainInfo, toolbar=Toolbar, domains = DomainIds, node = Node}) -> + Domains = maps:from_list([{Id, Domain} || Domain = #{id := Id} <- erpc:call(Node, virtuerl_mgt, domains_list, [])]), wxGridBagSizer:clear(DomainInfo, [{delete_windows, true}]), DomainId = lists:nth(ItemIndex + 1, DomainIds), @@ -277,7 +279,7 @@ handle_event(#wx{event = #wxList{type = command_list_item_selected, %% wxGridBagSizer:add(DomainInfo, SerialOut, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), %% WebView = wxWebView:new(DomainPanel, 999, [{url, "http://0.0.0.0:9000/noVNC-1.4.0/vnc.html?port=5700&?path=&resize=scale&autoconnect=true"}]), %% wxGridBagSizer:add(DomainInfo, WebView, {3, 0}, [{span, {1, 2}}, {flag, ?wxEXPAND}]), - VncWindow = virtuerl_vnc:start(DomainPanel, DomainId), + VncWindow = virtuerl_vnc:start(DomainPanel, DomainId, Node), wxGridBagSizer:add(DomainInfo, VncWindow, {0, 2}, [{span, {3, 1}}, {flag, ?wxEXPAND}]), wxGridBagSizer:addGrowableRow(DomainInfo, 2), @@ -296,13 +298,13 @@ handle_event(#wx{event = #wxList{type = command_list_item_selected, wxPanel:layout(DomainPanel), io:format("dblclick ~p (~p)~n", [DomainId, Domain]), {noreply, State}; -handle_event(#wx{id = 4044, event = #wxCommand{type = command_button_clicked}}, #state{domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 4044, event = #wxCommand{type = command_button_clicked}}, #state{domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), - {ok, Domain} = virtuerl_mgt:domain_get(#{id => DomainId}), - create_domain_dialog(Domain), + {ok, Domain} = erpc:call(Node, virtuerl_mgt, domain_get, [#{id => DomainId}]), + create_domain_dialog(Node, Domain), {noreply, State}; -handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), @@ -310,9 +312,9 @@ handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu io:format("~p~n", [Choice]), wxToolBar:enableTool(Toolbar, 100, false), wxToolBar:enableTool(Toolbar, 101, true), - ok = virtuerl_mgt:domain_start(Choice), + ok = erpc:call(Node, virtuerl_mgt, domain_start, [Choice]), {noreply, State}; -handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), @@ -320,9 +322,9 @@ handle_event(#wx{id = 101, obj = Toolbar, event = #wxCommand{type = command_menu io:format("~p~n", [Choice]), wxToolBar:enableTool(Toolbar, 100, true), wxToolBar:enableTool(Toolbar, 101, false), - ok = virtuerl_mgt:domain_stop(Choice), + ok = erpc:call(Node, virtuerl_mgt, domain_stop, [Choice]), {noreply, State}; -handle_event(#wx{id = 102, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> +handle_event(#wx{id = 102, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), DomainId = lists:nth(SelectedItem + 1, DomainIds), @@ -330,19 +332,19 @@ handle_event(#wx{id = 102, obj = Toolbar, event = #wxCommand{type = command_menu io:format("~p~n", [Choice]), %% wxToolBar:enableTool(Toolbar, 100, true), %% wxToolBar:enableTool(Toolbar, 101, false), -%% ok = virtuerl_mgt:domain_stop(Choice), - virtuerl_mgt:domain_delete(#{id => DomainId}), +%% ok = erpc:call(Node, virtuerl_mgt, domain_stop, (Choice), + erpc:call(Node, virtuerl_mgt, domain_delete, [#{id => DomainId}]), {noreply, State}; -handle_event(#wx{id = 103, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds} = State) -> - create_domain_dialog(#{network_id => "", name=> "", user_data => "", vcpu => 2, memory => 1024}), +handle_event(#wx{id = 103, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> + create_domain_dialog(Node, #{network_id => "", name=> "", user_data => "", vcpu => 2, memory => 1024}), {noreply, State}; %% BEGIN: Network Toolbar -handle_event(#wx{id = 102, event = #wxCommand{type = command_menu_selected}}, #state{page = 0, net_list_box = ListBox} = State) -> +handle_event(#wx{id = 102, event = #wxCommand{type = command_menu_selected}}, #state{page = 0, net_list_box = ListBox, node = Node} = State) -> NetId = wxListBox:getStringSelection(ListBox), - virtuerl_ipam:ipam_delete_net(NetId), + erpc:call(Node, virtuerl_ipam, ipam_delete_net, [NetId]), {noreply, State}; -handle_event(#wx{id = 103, event = #wxCommand{type = command_menu_selected}}, #state{page = 0} = State) -> - create_network_dialog(), +handle_event(#wx{id = 103, event = #wxCommand{type = command_menu_selected}}, #state{page = 0, node = Node} = State) -> + create_network_dialog(Node), {noreply, State}; %% END: Network Toolbar handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) -> @@ -365,7 +367,7 @@ code_change(_, _, State) -> terminate(_Reason, _State) -> ok. -create_network_dialog() -> +create_network_dialog(Node) -> Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Network", [{size, {1000, 500}}]), DialogSizer = wxBoxSizer:new(?wxVERTICAL), DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), @@ -381,13 +383,13 @@ create_network_dialog() -> case wxDialog:showModal(Dialog) of ?wxID_OK -> NetDef = virtuerl_net:parse_cidr(wxTextCtrl:getValue(CidrCtrl)), - {ok, NetId} = virtuerl_ipam:ipam_create_net([NetDef]); + {ok, NetId} = erpc:call(Node, virtuerl_ipam, ipam_create_net, [[NetDef]]); _ -> ok end, wxDialog:destroy(Dialog). -create_domain_dialog(#{network_id := NetworkId, name:= DomainName, user_data := UserData, vcpu := Vcpu, memory := Memory} = Domain) -> - {ok, Nets} = virtuerl_ipam:ipam_list_nets(), +create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_data := UserData, vcpu := Vcpu, memory := Memory} = Domain) -> + {ok, Nets} = erpc:call(Node, virtuerl_ipam, ipam_list_nets, []), Choices = maps:keys(Nets), Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Domain", [{size, {1000, 500}}]), DialogSizer = wxBoxSizer:new(?wxVERTICAL), @@ -417,15 +419,15 @@ create_domain_dialog(#{network_id := NetworkId, name:= DomainName, user_data := case wxDialog:showModal(Dialog) of ?wxID_OK -> io:format("true ~p~n", [wxChoice:getStringSelection(NetworkChoice)]), - virtuerl_mgt:domain_create(#{ + erpc:call(Node, virtuerl_mgt, domain_create, [#{ name => wxTextCtrl:getValue(NameCtrl), network_id => list_to_binary(wxChoice:getStringSelection(NetworkChoice)), user_data => wxStyledTextCtrl:getText(UserDataCtrl), vcpu => wxSpinCtrl:getValue(VcpuCtrl), memory => wxSpinCtrl:getValue(MemoryCtrl) - }); + }]); _ -> ok end, wxDialog:destroy(Dialog); -create_domain_dialog(Domain) -> - create_domain_dialog(Domain#{user_data => ""}). +create_domain_dialog(Node, Domain) -> + create_domain_dialog(Node, Domain#{user_data => ""}). diff --git a/virtuerl/src/virtuerl_util.erl b/virtuerl/src/virtuerl_util.erl index 0880de6..a253298 100644 --- a/virtuerl/src/virtuerl_util.erl +++ b/virtuerl/src/virtuerl_util.erl @@ -10,7 +10,7 @@ -author("ilya-stroeer"). %% API --export([uuid4/0, mac_to_str/1, delete_file/1]). +-export([uuid4/0, mac_to_str/1, delete_file/1, cmd/1]). uuid4() -> ID = string:lowercase(binary:encode_hex(<<(rand:uniform(16#FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)-1):128>>)), @@ -28,3 +28,10 @@ delete_file(Filename) -> {error, enoent} -> ok; Other -> Other end. + +cmd(Cmd) -> + Port = open_port({spawn, Cmd}, [exit_status]), + receive + {Port, {exit_status, 0}} -> ok; + {Port, {exit_signal, _}} -> error + end. diff --git a/virtuerl/src/virtuerl_vnc.erl b/virtuerl/src/virtuerl_vnc.erl index 5dc343d..265ed7b 100644 --- a/virtuerl/src/virtuerl_vnc.erl +++ b/virtuerl/src/virtuerl_vnc.erl @@ -33,7 +33,7 @@ -export([ init/1, handle_info/2, handle_event/2, code_change/3, terminate/2]). --export([start/2]). +-export([start/3]). -behaviour(wx_object). @@ -51,11 +51,11 @@ -record(state, {win, socket, panel, tex_id, vnc_conf, parent}). -record(vnc_conf, {width, height}). -start(Parent, DomainId) -> - wx_object:start_link(?MODULE, [Parent, DomainId], []). +start(Parent, DomainId, Node) -> + wx_object:start_link(?MODULE, [Parent, DomainId, Node], []). %% Init is called in the new process. -init([Parent, DomainId]) -> +init([Parent, DomainId, Node]) -> {Mx, My, _, _} = wxWindow:getTextExtent(Parent, "M"), %% wxFrame:setClientSize(Frame, {60*Mx, 20*My}), Panel = wxGLCanvas:new(Parent, [{attribList, [?WX_GL_RGBA,?WX_GL_DOUBLEBUFFER,0]}]), @@ -67,7 +67,7 @@ init([Parent, DomainId]) -> wxGLCanvas:setCurrent(Panel, Context), - VncProxy = virtuerl_vnc_proxy:start(DomainId), + VncProxy = virtuerl_vnc_proxy:start(DomainId, Node), {VncWidth, VncHeight} = receive {conf, TVncWidth, TVncHeight} -> {TVncWidth, TVncHeight} after 1000 -> diff --git a/virtuerl/src/virtuerl_vnc_proxy.erl b/virtuerl/src/virtuerl_vnc_proxy.erl index cec75b5..78bd607 100644 --- a/virtuerl/src/virtuerl_vnc_proxy.erl +++ b/virtuerl/src/virtuerl_vnc_proxy.erl @@ -6,7 +6,7 @@ %%%------------------------------------------------------------------- -module(virtuerl_vnc_proxy). --export([start/1]). +-export([start/2]). -define(SERVER, ?MODULE). -define(APPLICATION, virtuerl). @@ -29,10 +29,10 @@ %%% Spawning and gen_server implementation %%%=================================================================== -start(DomainId) -> +start(DomainId, Node) -> VncSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId, "vnc.sock"]), Self = self(), - spawn(fun() -> init(VncSocketPath, Self) end). + spawn(Node, fun() -> init(VncSocketPath, Self) end). init(VncSocketPath, Sender) -> {ok, Socket} = gen_tcp:connect({local, VncSocketPath}, 0, [{active, true}, binary, local]), From c6efdfcbc8014ab8bf285bdb5b3b05b76ef0b54a Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Mon, 11 Mar 2024 18:08:45 +0100 Subject: [PATCH 37/51] virtuerl: remove unused stuff --- virtuerl/config/sys.config | 7 - virtuerl/rebar.config | 12 +- virtuerl/rebar.lock | 29 +- virtuerl/src/pb/controller_pb.erl | 8217 ----------------- virtuerl/src/pb/controller_service_bhvr.erl | 157 - virtuerl/src/pb/controller_service_client.erl | 691 -- virtuerl/src/pb/daemon_pb.erl | 5962 ------------ virtuerl/src/pb/daemon_service_bhvr.erl | 109 - virtuerl/src/pb/daemon_service_client.erl | 475 - virtuerl/src/pb/dns_bhvr.erl | 25 - virtuerl/src/pb/dns_client.erl | 97 - virtuerl/src/pb/dns_pb.erl | 1228 --- virtuerl/src/pb/domain_pb.erl | 3401 ------- virtuerl/src/pb/domain_service_bhvr.erl | 45 - virtuerl/src/pb/domain_service_client.erl | 187 - virtuerl/src/pb/host_pb.erl | 1431 --- virtuerl/src/pb/host_service_bhvr.erl | 33 - virtuerl/src/pb/host_service_client.erl | 133 - virtuerl/src/pb/port_forwarding_pb.erl | 1320 --- .../src/pb/port_forwarding_service_bhvr.erl | 25 - .../src/pb/port_forwarding_service_client.erl | 97 - virtuerl/src/pb/route_pb.erl | 1912 ---- virtuerl/src/pb/route_service_bhvr.erl | 45 - virtuerl/src/pb/route_service_client.erl | 187 - virtuerl/src/pb/volume_pb.erl | 2159 ----- virtuerl/src/pb/volume_service_bhvr.erl | 45 - virtuerl/src/pb/volume_service_client.erl | 187 - virtuerl/src/virtuerl.app.src | 3 +- virtuerl/src/virtuerl_api_domain_col.erl | 58 - virtuerl/src/virtuerl_api_domain_res.erl | 58 - 30 files changed, 4 insertions(+), 28331 deletions(-) delete mode 100644 virtuerl/src/pb/controller_pb.erl delete mode 100644 virtuerl/src/pb/controller_service_bhvr.erl delete mode 100644 virtuerl/src/pb/controller_service_client.erl delete mode 100644 virtuerl/src/pb/daemon_pb.erl delete mode 100644 virtuerl/src/pb/daemon_service_bhvr.erl delete mode 100644 virtuerl/src/pb/daemon_service_client.erl delete mode 100644 virtuerl/src/pb/dns_bhvr.erl delete mode 100644 virtuerl/src/pb/dns_client.erl delete mode 100644 virtuerl/src/pb/dns_pb.erl delete mode 100644 virtuerl/src/pb/domain_pb.erl delete mode 100644 virtuerl/src/pb/domain_service_bhvr.erl delete mode 100644 virtuerl/src/pb/domain_service_client.erl delete mode 100644 virtuerl/src/pb/host_pb.erl delete mode 100644 virtuerl/src/pb/host_service_bhvr.erl delete mode 100644 virtuerl/src/pb/host_service_client.erl delete mode 100644 virtuerl/src/pb/port_forwarding_pb.erl delete mode 100644 virtuerl/src/pb/port_forwarding_service_bhvr.erl delete mode 100644 virtuerl/src/pb/port_forwarding_service_client.erl delete mode 100644 virtuerl/src/pb/route_pb.erl delete mode 100644 virtuerl/src/pb/route_service_bhvr.erl delete mode 100644 virtuerl/src/pb/route_service_client.erl delete mode 100644 virtuerl/src/pb/volume_pb.erl delete mode 100644 virtuerl/src/pb/volume_service_bhvr.erl delete mode 100644 virtuerl/src/pb/volume_service_client.erl delete mode 100644 virtuerl/src/virtuerl_api_domain_col.erl delete mode 100644 virtuerl/src/virtuerl_api_domain_res.erl diff --git a/virtuerl/config/sys.config b/virtuerl/config/sys.config index c65080a..d445da2 100644 --- a/virtuerl/config/sys.config +++ b/virtuerl/config/sys.config @@ -5,12 +5,5 @@ #{ level => debug, formatter => {logger_formatter, #{single_line => false}}}} ]}]}, - {grpcbox, [ - {client, #{channels => [{default_channel, [{https, "verbit.in-berlin.de", 8443, [ - {certfile, "config/client.crt"}, - {keyfile, "config/client.key"}, - {cacertfile, "config/ca.crt"} - ]}], #{}}]}} - ]}, {erlexec, [{root, true}, {user, "root"}]} ]. diff --git a/virtuerl/rebar.config b/virtuerl/rebar.config index 6596040..94af93d 100644 --- a/virtuerl/rebar.config +++ b/virtuerl/rebar.config @@ -2,24 +2,16 @@ {deps, [ {khepri, "0.7.0"}, {thoas, "1.0.0"}, - {grpcbox, "0.16.0"}, - {cowboy, "2.10.0"}, {mochiweb, "3.1.2"}, {erlexec, "~> 2.0"} ]}. {relx, [ {release, {virtuerl, git}, [virtuerl, {khepri, load}, {mnesia, load}, erts]}, - {mode, prod} + {mode, prod}, + {extended_start_script, false} ]}. -{plugins, [grpcbox_plugin]}. -{grpc, [ - {out_dir, "src/pb"}, - {protos, "../protos/minivirt"}, - {gpb_opts, [{module_name_suffix, "_pb"}, {i, "../protos"}, {o, "src/pb"}]} - ]}. - {shell, [ {config, "config/sys.config"}, {apps, [virtuerl]} diff --git a/virtuerl/rebar.lock b/virtuerl/rebar.lock index 347e593..f90d145 100644 --- a/virtuerl/rebar.lock +++ b/virtuerl/rebar.lock @@ -1,59 +1,32 @@ {"1.2.0", -[{<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},1}, - {<<"aten">>,{pkg,<<"aten">>,<<"0.5.8">>},2}, - {<<"chatterbox">>,{pkg,<<"ts_chatterbox">>,<<"0.13.0">>},1}, - {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.10.0">>},0}, - {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.12.1">>},1}, - {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},1}, +[{<<"aten">>,{pkg,<<"aten">>,<<"0.5.8">>},2}, {<<"erlexec">>,{pkg,<<"erlexec">>,<<"2.0.2">>},0}, {<<"gen_batch_server">>,{pkg,<<"gen_batch_server">>,<<"0.8.8">>},2}, - {<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1}, - {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.16.0">>},0}, {<<"horus">>,{pkg,<<"horus">>,<<"0.2.3">>},1}, - {<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},2}, {<<"khepri">>,{pkg,<<"khepri">>,<<"0.7.0">>},0}, {<<"mochiweb">>,{pkg,<<"mochiweb">>,<<"3.1.2">>},0}, {<<"ra">>,{pkg,<<"ra">>,<<"2.5.1">>},1}, - {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, {<<"seshat">>,{pkg,<<"seshat">>,<<"0.4.0">>},2}, {<<"thoas">>,{pkg,<<"thoas">>,<<"1.0.0">>},0}]}. [ {pkg_hash,[ - {<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>}, {<<"aten">>, <<"B5C97F48517C4F37F26A519AA57A00A31FF1B8EA4324EC1CAE27F818ED5C0DB2">>}, - {<<"chatterbox">>, <<"6F059D97BCAA758B8EA6FFFE2B3B81362BD06B639D3EA2BB088335511D691EBF">>}, - {<<"cowboy">>, <<"FF9FFEFF91DAE4AE270DD975642997AFE2A1179D94B1887863E43F681A203E26">>}, - {<<"cowlib">>, <<"A9FA9A625F1D2025FE6B462CB865881329B5CAFF8F1854D1CBC9F9533F00E1E1">>}, - {<<"ctx">>, <<"8FF88B70E6400C4DF90142E7F130625B82086077A45364A78D208ED3ED53C7FE">>}, {<<"erlexec">>, <<"995E40477DE94C37EC1264CC3E52EB6273938E80C9BCC4F94110A3F1C0D9ABA3">>}, {<<"gen_batch_server">>, <<"7840A1FA63EE1EFFC83E8A91D22664847A2BA1192D30EAFFFD914ACB51578068">>}, - {<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>}, - {<<"grpcbox">>, <<"B83F37C62D6EECA347B77F9B1EC7E9F62231690CDFEB3A31BE07CD4002BA9C82">>}, {<<"horus">>, <<"A8AC0E7B335B83860ECECFA12EE4CB50289A15A515175BEF804A9C0D06C619B5">>}, - {<<"hpack">>, <<"17670F83FF984AE6CD74B1C456EDDE906D27FF013740EE4D9EFAA4F1BF999633">>}, {<<"khepri">>, <<"5CB9B1D35051DAEAF6308BFC64446A4BC2DEAAAE39C619DFB890B6CCFF8F45AF">>}, {<<"mochiweb">>, <<"D872D470DBBA367171A38C41592B19DE370854E74C8621BF0C6FE39B17CDD1CF">>}, {<<"ra">>, <<"9EE208B7CD229B34F67C56B6BEFAD0E906C5B37C6175DB9C76C00B1BC0CF82D8">>}, - {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"seshat">>, <<"1D5DC4294E36B8745245AB2649E24E39D7B6B1209D7A6484F2B8D706C35C9814">>}, {<<"thoas">>, <<"567C03902920827A18A89F05B79A37B5BF93553154B883E0131801600CF02CE0">>}]}, {pkg_hash_ext,[ - {<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>}, {<<"aten">>, <<"64D40A8CF0DDFEA4E13AF00B7327F0925147F83612D0627D9506CBFFE90C13EF">>}, - {<<"chatterbox">>, <<"B93D19104D86AF0B3F2566C4CBA2A57D2E06D103728246BA1AC6C3C0FF010AA7">>}, - {<<"cowboy">>, <<"3AFDCCB7183CC6F143CB14D3CF51FA00E53DB9EC80CDCD525482F5E99BC41D6B">>}, - {<<"cowlib">>, <<"163B73F6367A7341B33C794C4E88E7DBFE6498AC42DCD69EF44C5BC5507C8DB0">>}, - {<<"ctx">>, <<"A14ED2D1B67723DBEBBE423B28D7615EB0BDCBA6FF28F2D1F1B0A7E1D4AA5FC2">>}, {<<"erlexec">>, <<"CC829A7C6C23D399832DA2E998EA5EBC552232A6FE3EB1EDB400178EC8287DCB">>}, {<<"gen_batch_server">>, <<"C3E6A1A2A0FB62AEE631A98CFA0FD8903E9562422CBF72043953E2FB1D203017">>}, - {<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>}, - {<<"grpcbox">>, <<"294DF743AE20A7E030889F00644001370A4F7CE0121F3BBDAF13CF3169C62913">>}, {<<"horus">>, <<"0CA6AA70A348F73EF0B78F498C82F9C29F49B45D5915B890945A1C326A216C10">>}, - {<<"hpack">>, <<"06F580167C4B8B8A6429040DF36CC93BBA6D571FAEAEC1B28816523379CBB23A">>}, {<<"khepri">>, <<"784D90A578340E137BF7E2C8D1F1F45E59D6E13262804A841BF9E709E7505954">>}, {<<"mochiweb">>, <<"A8609035711F9264E8ABE54312D1B1645374B9E08986AE06E979BB0AC8B99F9F">>}, {<<"ra">>, <<"13B03F02CF6C1837C527EDD4A953F0C09DA0ABAD0AF6985B64BFD66943C4C5C3">>}, - {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"seshat">>, <<"2C3DEEC7FF86E0D0C05EDEBD3455C8363123C227BE292FFFFC1A05EEC08BFF63">>}, {<<"thoas">>, <<"FC763185B932ECB32A554FB735EE03C3B6B1B31366077A2427D2A97F3BD26735">>}]} ]. diff --git a/virtuerl/src/pb/controller_pb.erl b/virtuerl/src/pb/controller_pb.erl deleted file mode 100644 index f6bad6d..0000000 --- a/virtuerl/src/pb/controller_pb.erl +++ /dev/null @@ -1,8217 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(controller_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type empty() :: - #{ - }. - --type sync_routes_request() :: - #{ - }. - --type start_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata() % = 2, optional - }. - --type stop_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata(), % = 2, optional - force => boolean() | 0 | 1 % = 3, optional - }. - --type get_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type domain() :: - #{id => non_neg_integer(), % = 1, optional, 64 bits - uuid => unicode:chardata(), % = 2, optional - name => unicode:chardata(), % = 3, optional - vcpu => non_neg_integer(), % = 4, optional, 32 bits - memory => non_neg_integer(), % = 5, optional, 64 bits - network => unicode:chardata(), % = 6, optional - bridge => unicode:chardata(), % = 7, optional - state => unicode:chardata(), % = 8, optional - private_ip => unicode:chardata(), % = 9, optional - ipv6_address => unicode:chardata(), % = 15, optional - user_data => unicode:chardata(), % = 10, optional - nested_virtualization => boolean() | 0 | 1, % = 11, optional - base_image => unicode:chardata(), % = 12, optional - created_at => timestamp(), % = 13, optional - os_type => unicode:chardata() % = 14, optional - }. - --type list_domains_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_domains_response() :: - #{domains => [domain()] % = 1, repeated - }. - --type create_domain_request() :: - #{domain => domain(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type download_image_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type image_chunk() :: - #{bytes => iodata() % = 1, optional - }. - --type get_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type network() :: - #{uuid => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - cidr => unicode:chardata(), % = 3, optional - cidr6 => unicode:chardata() % = 4, optional - }. - --type list_networks_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_networks_response() :: - #{networks => [network()] % = 1, repeated - }. - --type create_network_request() :: - #{network => network(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type get_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume() :: - #{id => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - size => non_neg_integer() % = 3, optional, 64 bits - }. - --type list_volumes_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_volumes_response() :: - #{volumes => [volume()] % = 1, repeated - }. - --type create_volume_request() :: - #{volume => volume(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type update_volume_request() :: - #{host => unicode:chardata(), % = 1, optional - volume => volume() % = 2, optional - }. - --type delete_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume_attachment_identifier() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - host => unicode:chardata() % = 3, optional - }. - --type volume_attachment() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - disk_address => unicode:chardata() % = 3, optional - }. - --type list_volume_attachments_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type list_volume_attachments_response() :: - #{attachments => [volume_attachment()] % = 1, repeated - }. - --type port_forwarding_identifier() :: - #{host => unicode:chardata(), % = 1, optional - protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer() % = 3, optional, 32 bits - }. - --type port_forwarding() :: - #{protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer(), % = 3, optional, 32 bits - target_ip => unicode:chardata(), % = 4, optional - target_port => non_neg_integer() % = 5, optional, 32 bits - }. - --type list_port_forwardings_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_port_forwardings_response() :: - #{port_forwardings => [port_forwarding()] % = 1, repeated - }. - --type put_port_forwarding_request() :: - #{port_forwarding => port_forwarding(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type dns_record_identifier() :: - #{name => unicode:chardata(), % = 1, optional - type => unicode:chardata() % = 2, optional - }. - --type dns_record() :: - #{name => unicode:chardata(), % = 1, optional - type => unicode:chardata(), % = 2, optional - ttl => non_neg_integer(), % = 3, optional, 64 bits - records => [unicode:chardata()] % = 4, repeated - }. - --type list_dns_records_request() :: - #{ - }. - --type list_dns_records_response() :: - #{dns_records => [dns_record()] % = 1, repeated - }. - --type put_dns_record_request() :: - #{dns_record => dns_record() % = 1, optional - }. - --type route_table() :: - #{network_name => unicode:chardata(), % = 1, optional - id => non_neg_integer(), % = 2, optional, 32 bits - name => unicode:chardata() % = 3, optional - }. - --type route_table_identifier() :: - #{id => non_neg_integer() % = 1, optional, 32 bits - }. - --type list_route_tables_request() :: - #{network_name => unicode:chardata() % = 1, optional - }. - --type list_route_tables_response() :: - #{route_tables => [route_table()] % = 1, repeated - }. - --type create_route_table_request() :: - #{route_table => route_table() % = 1, optional - }. - --type route_identifier() :: - #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits - destination => unicode:chardata() % = 2, optional - }. - --type route() :: - #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits - destination => unicode:chardata(), % = 2, optional - gateways => [unicode:chardata()] % = 3, repeated - }. - --type list_routes_request() :: - #{route_table_id => non_neg_integer() % = 1, optional, 32 bits - }. - --type list_routes_response() :: - #{routes => [route()] % = 1, repeated - }. - --type put_route_request() :: - #{route => route() % = 1, optional - }. - --type sync_request() :: - #{ - }. - --type timestamp() :: - #{seconds => integer(), % = 1, optional, 64 bits - nanos => integer() % = 2, optional, 32 bits - }. - --export_type(['empty'/0, 'sync_routes_request'/0, 'start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'dns_record_identifier'/0, 'dns_record'/0, 'list_dns_records_request'/0, 'list_dns_records_response'/0, 'put_dns_record_request'/0, 'route_table'/0, 'route_table_identifier'/0, 'list_route_tables_request'/0, 'list_route_tables_response'/0, 'create_route_table_request'/0, 'route_identifier'/0, 'route'/0, 'list_routes_request'/0, 'list_routes_response'/0, 'put_route_request'/0, 'sync_request'/0, 'timestamp'/0]). --type '$msg_name'() :: empty | sync_routes_request | start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | dns_record_identifier | dns_record | list_dns_records_request | list_dns_records_response | put_dns_record_request | route_table | route_table_identifier | list_route_tables_request | list_route_tables_response | create_route_table_request | route_identifier | route | list_routes_request | list_routes_response | put_route_request | sync_request | timestamp. --type '$msg'() :: empty() | sync_routes_request() | start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | dns_record_identifier() | dns_record() | list_dns_records_request() | list_dns_records_response() | put_dns_record_request() | route_table() | route_table_identifier() | list_route_tables_request() | list_route_tables_response() | create_route_table_request() | route_identifier() | route() | list_routes_request() | list_routes_response() | put_route_request() | sync_request() | timestamp(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); - sync_routes_request -> encode_msg_sync_routes_request(id(Msg, TrUserData), TrUserData); - start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); - stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); - get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); - domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); - list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); - list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); - create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); - delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); - download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); - image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); - get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); - network -> encode_msg_network(id(Msg, TrUserData), TrUserData); - list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); - list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); - create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); - delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); - get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); - volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); - list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); - list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); - create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); - update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); - delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); - volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); - volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); - list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); - list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); - port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); - port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); - list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); - list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); - put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); - dns_record_identifier -> encode_msg_dns_record_identifier(id(Msg, TrUserData), TrUserData); - dns_record -> encode_msg_dns_record(id(Msg, TrUserData), TrUserData); - list_dns_records_request -> encode_msg_list_dns_records_request(id(Msg, TrUserData), TrUserData); - list_dns_records_response -> encode_msg_list_dns_records_response(id(Msg, TrUserData), TrUserData); - put_dns_record_request -> encode_msg_put_dns_record_request(id(Msg, TrUserData), TrUserData); - route_table -> encode_msg_route_table(id(Msg, TrUserData), TrUserData); - route_table_identifier -> encode_msg_route_table_identifier(id(Msg, TrUserData), TrUserData); - list_route_tables_request -> encode_msg_list_route_tables_request(id(Msg, TrUserData), TrUserData); - list_route_tables_response -> encode_msg_list_route_tables_response(id(Msg, TrUserData), TrUserData); - create_route_table_request -> encode_msg_create_route_table_request(id(Msg, TrUserData), TrUserData); - route_identifier -> encode_msg_route_identifier(id(Msg, TrUserData), TrUserData); - route -> encode_msg_route(id(Msg, TrUserData), TrUserData); - list_routes_request -> encode_msg_list_routes_request(id(Msg, TrUserData), TrUserData); - list_routes_response -> encode_msg_list_routes_response(id(Msg, TrUserData), TrUserData); - put_route_request -> encode_msg_put_route_request(id(Msg, TrUserData), TrUserData); - sync_request -> encode_msg_sync_request(id(Msg, TrUserData), TrUserData); - timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -encode_msg_sync_routes_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{force := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= false -> B2; - true -> e_type_bool(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). - - -encode_msg_domain(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{name := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{vcpu := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{memory := F5} -> - begin - TrF5 = id(F5, TrUserData), - if TrF5 =:= 0 -> B4; - true -> e_varint(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{network := F6} -> - begin - TrF6 = id(F6, TrUserData), - case is_empty_string(TrF6) of - true -> B5; - false -> e_type_string(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - B7 = case M of - #{bridge := F7} -> - begin - TrF7 = id(F7, TrUserData), - case is_empty_string(TrF7) of - true -> B6; - false -> e_type_string(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end, - B8 = case M of - #{state := F8} -> - begin - TrF8 = id(F8, TrUserData), - case is_empty_string(TrF8) of - true -> B7; - false -> e_type_string(TrF8, <>, TrUserData) - end - end; - _ -> B7 - end, - B9 = case M of - #{private_ip := F9} -> - begin - TrF9 = id(F9, TrUserData), - case is_empty_string(TrF9) of - true -> B8; - false -> e_type_string(TrF9, <>, TrUserData) - end - end; - _ -> B8 - end, - B10 = case M of - #{ipv6_address := F10} -> - begin - TrF10 = id(F10, TrUserData), - case is_empty_string(TrF10) of - true -> B9; - false -> e_type_string(TrF10, <>, TrUserData) - end - end; - _ -> B9 - end, - B11 = case M of - #{user_data := F11} -> - begin - TrF11 = id(F11, TrUserData), - case is_empty_string(TrF11) of - true -> B10; - false -> e_type_string(TrF11, <>, TrUserData) - end - end; - _ -> B10 - end, - B12 = case M of - #{nested_virtualization := F12} -> - begin - TrF12 = id(F12, TrUserData), - if TrF12 =:= false -> B11; - true -> e_type_bool(TrF12, <>, TrUserData) - end - end; - _ -> B11 - end, - B13 = case M of - #{base_image := F13} -> - begin - TrF13 = id(F13, TrUserData), - case is_empty_string(TrF13) of - true -> B12; - false -> e_type_string(TrF13, <>, TrUserData) - end - end; - _ -> B12 - end, - B14 = case M of - #{created_at := F14} -> - begin - TrF14 = id(F14, TrUserData), - if TrF14 =:= undefined -> B13; - true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) - end - end; - _ -> B13 - end, - case M of - #{os_type := F15} -> - begin - TrF15 = id(F15, TrUserData), - case is_empty_string(TrF15) of - true -> B14; - false -> e_type_string(TrF15, <>, TrUserData) - end - end; - _ -> B14 - end. - -encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> - case M of - #{domains := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). - - -encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). - - -encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> - case M of - #{bytes := F1} -> - begin - TrF1 = id(F1, TrUserData), - case iolist_size(TrF1) of - 0 -> Bin; - _ -> e_type_bytes(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). - - -encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). - - -encode_msg_network(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{cidr := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{cidr6 := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> - case M of - #{networks := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). - - -encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{network := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). - - -encode_msg_volume(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{size := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> - case M of - #{volumes := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{volume := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{volume := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= undefined -> B1; - true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{host := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{disk_address := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> - case M of - #{attachments := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{protocol := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{source_port := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{protocol := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{source_port := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{target_ip := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{target_port := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> - case M of - #{port_forwardings := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). - - -encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{port_forwarding := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_dns_record_identifier(Msg, TrUserData) -> encode_msg_dns_record_identifier(Msg, <<>>, TrUserData). - - -encode_msg_dns_record_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{type := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_dns_record(Msg, TrUserData) -> encode_msg_dns_record(Msg, <<>>, TrUserData). - - -encode_msg_dns_record(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{type := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{ttl := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{records := F4} -> - TrF4 = id(F4, TrUserData), - if TrF4 == [] -> B3; - true -> e_field_dns_record_records(TrF4, B3, TrUserData) - end; - _ -> B3 - end. - -encode_msg_list_dns_records_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_list_dns_records_response(Msg, TrUserData) -> encode_msg_list_dns_records_response(Msg, <<>>, TrUserData). - - -encode_msg_list_dns_records_response(#{} = M, Bin, TrUserData) -> - case M of - #{dns_records := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_dns_records_response_dns_records(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_dns_record_request(Msg, TrUserData) -> encode_msg_put_dns_record_request(Msg, <<>>, TrUserData). - - -encode_msg_put_dns_record_request(#{} = M, Bin, TrUserData) -> - case M of - #{dns_record := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_dns_record_request_dns_record(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_route_table(Msg, TrUserData) -> encode_msg_route_table(Msg, <<>>, TrUserData). - - -encode_msg_route_table(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{network_name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{id := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{name := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_route_table_identifier(Msg, TrUserData) -> encode_msg_route_table_identifier(Msg, <<>>, TrUserData). - - -encode_msg_route_table_identifier(#{} = M, Bin, TrUserData) -> - case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_route_tables_request(Msg, TrUserData) -> encode_msg_list_route_tables_request(Msg, <<>>, TrUserData). - - -encode_msg_list_route_tables_request(#{} = M, Bin, TrUserData) -> - case M of - #{network_name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_route_tables_response(Msg, TrUserData) -> encode_msg_list_route_tables_response(Msg, <<>>, TrUserData). - - -encode_msg_list_route_tables_response(#{} = M, Bin, TrUserData) -> - case M of - #{route_tables := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_route_tables_response_route_tables(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_route_table_request(Msg, TrUserData) -> encode_msg_create_route_table_request(Msg, <<>>, TrUserData). - - -encode_msg_create_route_table_request(#{} = M, Bin, TrUserData) -> - case M of - #{route_table := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_route_table_request_route_table(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_route_identifier(Msg, TrUserData) -> encode_msg_route_identifier(Msg, <<>>, TrUserData). - - -encode_msg_route_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{destination := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_route(Msg, TrUserData) -> encode_msg_route(Msg, <<>>, TrUserData). - - -encode_msg_route(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{destination := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{gateways := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> e_field_route_gateways(TrF3, B2, TrUserData) - end; - _ -> B2 - end. - -encode_msg_list_routes_request(Msg, TrUserData) -> encode_msg_list_routes_request(Msg, <<>>, TrUserData). - - -encode_msg_list_routes_request(#{} = M, Bin, TrUserData) -> - case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_routes_response(Msg, TrUserData) -> encode_msg_list_routes_response(Msg, <<>>, TrUserData). - - -encode_msg_list_routes_response(#{} = M, Bin, TrUserData) -> - case M of - #{routes := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_routes_response_routes(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_route_request(Msg, TrUserData) -> encode_msg_put_route_request(Msg, <<>>, TrUserData). - - -encode_msg_put_route_request(#{} = M, Bin, TrUserData) -> - case M of - #{route := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_route_request_route(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_sync_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). - - -encode_msg_timestamp(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{seconds := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_type_int64(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{nanos := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_type_int32(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -e_mfield_domain_created_at(Msg, Bin, TrUserData) -> - SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_domains_response_domains(Rest, Bin3, TrUserData); -e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. - -e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_networks_response_networks(Rest, Bin3, TrUserData); -e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. - -e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); -e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. - -e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); -e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. - -e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); -e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. - -e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_dns_record_records([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), - e_field_dns_record_records(Rest, Bin3, TrUserData); -e_field_dns_record_records([], Bin, _TrUserData) -> Bin. - -e_mfield_list_dns_records_response_dns_records(Msg, Bin, TrUserData) -> - SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_dns_records_response_dns_records([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_dns_records_response_dns_records(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_dns_records_response_dns_records(Rest, Bin3, TrUserData); -e_field_list_dns_records_response_dns_records([], Bin, _TrUserData) -> Bin. - -e_mfield_put_dns_record_request_dns_record(Msg, Bin, TrUserData) -> - SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_route_tables_response_route_tables(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_route_tables_response_route_tables([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_route_tables_response_route_tables(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_route_tables_response_route_tables(Rest, Bin3, TrUserData); -e_field_list_route_tables_response_route_tables([], Bin, _TrUserData) -> Bin. - -e_mfield_create_route_table_request_route_table(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_route_gateways([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), - e_field_route_gateways(Rest, Bin3, TrUserData); -e_field_route_gateways([], Bin, _TrUserData) -> Bin. - -e_mfield_list_routes_response_routes(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_routes_response_routes([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_routes_response_routes(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_routes_response_routes(Rest, Bin3, TrUserData); -e_field_list_routes_response_routes([], Bin, _TrUserData) -> Bin. - -e_mfield_put_route_request_route(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); -decode_msg_2_doit(sync_routes_request, Bin, TrUserData) -> id(decode_msg_sync_routes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(dns_record_identifier, Bin, TrUserData) -> id(decode_msg_dns_record_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(dns_record, Bin, TrUserData) -> id(decode_msg_dns_record(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_dns_records_request, Bin, TrUserData) -> id(decode_msg_list_dns_records_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_dns_records_response, Bin, TrUserData) -> id(decode_msg_list_dns_records_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_dns_record_request, Bin, TrUserData) -> id(decode_msg_put_dns_record_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route_table, Bin, TrUserData) -> id(decode_msg_route_table(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route_table_identifier, Bin, TrUserData) -> id(decode_msg_route_table_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_route_tables_request, Bin, TrUserData) -> id(decode_msg_list_route_tables_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_route_tables_response, Bin, TrUserData) -> id(decode_msg_list_route_tables_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_route_table_request, Bin, TrUserData) -> id(decode_msg_create_route_table_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route_identifier, Bin, TrUserData) -> id(decode_msg_route_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route, Bin, TrUserData) -> id(decode_msg_route(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_routes_request, Bin, TrUserData) -> id(decode_msg_list_routes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_routes_response, Bin, TrUserData) -> id(decode_msg_list_routes_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_route_request, Bin, TrUserData) -> id(decode_msg_put_route_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(sync_request, Bin, TrUserData) -> id(decode_msg_sync_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). - - - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -decode_msg_sync_routes_request(Bin, TrUserData) -> dfp_read_field_def_sync_routes_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_sync_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_routes_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_sync_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_sync_routes_request(Rest2, 0, 0, F, TrUserData). - -skip_group_sync_routes_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_sync_routes_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_sync_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_sync_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; -dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. - -d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). - -dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; -dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. - -d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_domain(Bin, TrUserData) -> - dfp_read_field_def_domain(Bin, - 0, - 0, - 0, - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(false, TrUserData), - id(<<>>, TrUserData), - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end; -dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> - dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) - end - end; -dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end. - -d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). - -d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, - 0, - 0, - F, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - F@_13, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) - end, - F@_15, - TrUserData). - -d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). - -skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end. - -d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end; -dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end. - -d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_domain(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; -dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. - -d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; -dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. - -d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end. - -d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end; -dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end. - -d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_network(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; -dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. - -d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end; -dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end. - -d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end; -dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end. - -d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, - 0, - 0, - F, - F@_1, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; -dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. - -d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; -dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. - -d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; -dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. - -d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; -dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. - -d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end. - -d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end; -dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end. - -d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_dns_record_identifier(Bin, TrUserData) -> dfp_read_field_def_dns_record_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_dns_record_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_dns_record_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_type(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}; -dfp_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_dns_record_identifier_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_dns_record_identifier_type(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}. - -d_field_dns_record_identifier_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_dns_record_identifier_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_dns_record_identifier_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_dns_record_identifier_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_dns_record_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_dns_record_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_dns_record_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_dns_record_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_dns_record_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_dns_record_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_dns_record_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_dns_record(Bin, TrUserData) -> dfp_read_field_def_dns_record(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id([], TrUserData), TrUserData). - -dfp_read_field_def_dns_record(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_ttl(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_records(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}; -dfp_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_dns_record_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 18 -> d_field_dns_record_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 24 -> d_field_dns_record_ttl(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_dns_record_records(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}. - -d_field_dns_record_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_dns_record_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_dns_record_ttl(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_ttl(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_ttl(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_dns_record_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_records(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, F@_3, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_dns_record(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_dns_record(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_dns_record(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_dns_record(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_dns_record(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_dns_record(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_dns_record(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_dns_records_request(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_list_dns_records_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_dns_records_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_list_dns_records_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_dns_records_request(Rest2, 0, 0, F, TrUserData). - -skip_group_list_dns_records_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_dns_records_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_list_dns_records_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_list_dns_records_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_list_dns_records_response(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_dns_records_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_dns_records_response_dns_records(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{dns_records => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_dns_records_response_dns_records(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{dns_records => lists_reverse(R1, TrUserData)} - end. - -d_field_list_dns_records_response_dns_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_dns_records_response_dns_records(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_dns_records_response_dns_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_dns_records_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_dns_records_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_dns_records_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_dns_records_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_dns_records_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_dns_records_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_dns_records_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_dns_records_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_dns_record_request(Bin, TrUserData) -> dfp_read_field_def_put_dns_record_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_put_dns_record_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_dns_record_request_dns_record(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{dns_record => F@_1} - end; -dfp_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_dns_record_request_dns_record(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{dns_record => F@_1} - end. - -d_field_put_dns_record_request_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_dns_record_request_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_put_dns_record_request_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_dns_record_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_dns_record(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_put_dns_record_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_put_dns_record_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_dns_record_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_put_dns_record_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_dns_record_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_put_dns_record_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_put_dns_record_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_route_table(Bin, TrUserData) -> dfp_read_field_def_route_table(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_route_table(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}; -dfp_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_route_table_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 16 -> d_field_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_route_table_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}. - -d_field_route_table_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_table(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_route_table_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_route_table(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_route_table(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_table(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_route_table(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_table(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_route_table(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_route_table(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_route_table_identifier(Bin, TrUserData) -> dfp_read_field_def_route_table_identifier(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). - -dfp_read_field_def_route_table_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_route_table_identifier_id(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}; -dfp_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_table_identifier_id(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}. - -d_field_route_table_identifier_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_route_table_identifier_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_route_table_identifier_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_table_identifier(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_route_table_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_route_table_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_table_identifier(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_route_table_identifier(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_table_identifier(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_route_table_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_route_table_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_route_tables_request(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_route_tables_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_request_network_name(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}; -dfp_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_route_tables_request_network_name(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}. - -d_field_list_route_tables_request_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_request_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_route_tables_request_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_route_tables_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_route_tables_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_route_tables_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_route_tables_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_route_tables_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_route_tables_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_route_tables_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_route_tables_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_route_tables_response(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_route_tables_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_response_route_tables(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{route_tables => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_route_tables_response_route_tables(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{route_tables => lists_reverse(R1, TrUserData)} - end. - -d_field_list_route_tables_response_route_tables(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_response_route_tables(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_route_tables_response_route_tables(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_route_tables_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_route_tables_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_route_tables_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_route_tables_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_route_tables_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_route_tables_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_route_tables_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_route_tables_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_route_table_request(Bin, TrUserData) -> dfp_read_field_def_create_route_table_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_create_route_table_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_route_table_request_route_table(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route_table => F@_1} - end; -dfp_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_route_table_request_route_table(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route_table => F@_1} - end. - -d_field_create_route_table_request_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_route_table_request_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_create_route_table_request_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_route_table_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_route_table(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_create_route_table_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_create_route_table_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_route_table_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_create_route_table_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_route_table_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_create_route_table_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_create_route_table_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_route_identifier(Bin, TrUserData) -> dfp_read_field_def_route_identifier(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_route_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_route_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_destination(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}; -dfp_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_identifier_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_route_identifier_destination(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}. - -d_field_route_identifier_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_route_identifier_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_route_identifier_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_route_identifier_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_route_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_route_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_route_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_route_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_route_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_route(Bin, TrUserData) -> dfp_read_field_def_route(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id([], TrUserData), TrUserData). - -dfp_read_field_def_route(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_destination(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_gateways(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}; -dfp_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_route(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_route_destination(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_route_gateways(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}. - -d_field_route_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_route_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_route_gateways(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_gateways(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_gateways(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_route(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_route(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_route(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_route(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_route(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_routes_request(Bin, TrUserData) -> dfp_read_field_def_list_routes_request(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). - -dfp_read_field_def_list_routes_request(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_request_route_table_id(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}; -dfp_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_list_routes_request_route_table_id(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}. - -d_field_list_routes_request_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_request_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_routes_request_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_list_routes_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_routes_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_routes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_routes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_routes_response(Bin, TrUserData) -> dfp_read_field_def_list_routes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_routes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_response_routes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{routes => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_routes_response_routes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{routes => lists_reverse(R1, TrUserData)} - end. - -d_field_list_routes_response_routes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_response_routes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_routes_response_routes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_routes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_routes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_routes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_routes_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_routes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_routes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_routes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_routes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_route_request(Bin, TrUserData) -> dfp_read_field_def_put_route_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_put_route_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_route_request_route(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route => F@_1} - end; -dfp_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_route_request_route(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route => F@_1} - end. - -d_field_put_route_request_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_route_request_route(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_put_route_request_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_route_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_route(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_put_route_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_put_route_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_route_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_put_route_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_route_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_put_route_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_put_route_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_sync_request(Bin, TrUserData) -> dfp_read_field_def_sync_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_sync_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_sync_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_sync_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_sync_request(Rest2, 0, 0, F, TrUserData). - -skip_group_sync_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_sync_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_sync_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_sync_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; -dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. - -d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - empty -> merge_msg_empty(Prev, New, TrUserData); - sync_routes_request -> merge_msg_sync_routes_request(Prev, New, TrUserData); - start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); - stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); - get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); - domain -> merge_msg_domain(Prev, New, TrUserData); - list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); - list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); - create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); - delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); - download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); - image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); - get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); - network -> merge_msg_network(Prev, New, TrUserData); - list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); - list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); - create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); - delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); - get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); - volume -> merge_msg_volume(Prev, New, TrUserData); - list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); - list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); - create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); - update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); - delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); - volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); - volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); - list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); - list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); - port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); - port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); - list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); - list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); - put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); - dns_record_identifier -> merge_msg_dns_record_identifier(Prev, New, TrUserData); - dns_record -> merge_msg_dns_record(Prev, New, TrUserData); - list_dns_records_request -> merge_msg_list_dns_records_request(Prev, New, TrUserData); - list_dns_records_response -> merge_msg_list_dns_records_response(Prev, New, TrUserData); - put_dns_record_request -> merge_msg_put_dns_record_request(Prev, New, TrUserData); - route_table -> merge_msg_route_table(Prev, New, TrUserData); - route_table_identifier -> merge_msg_route_table_identifier(Prev, New, TrUserData); - list_route_tables_request -> merge_msg_list_route_tables_request(Prev, New, TrUserData); - list_route_tables_response -> merge_msg_list_route_tables_response(Prev, New, TrUserData); - create_route_table_request -> merge_msg_create_route_table_request(Prev, New, TrUserData); - route_identifier -> merge_msg_route_identifier(Prev, New, TrUserData); - route -> merge_msg_route(Prev, New, TrUserData); - list_routes_request -> merge_msg_list_routes_request(Prev, New, TrUserData); - list_routes_response -> merge_msg_list_routes_response(Prev, New, TrUserData); - put_route_request -> merge_msg_put_route_request(Prev, New, TrUserData); - sync_request -> merge_msg_sync_request(Prev, New, TrUserData); - timestamp -> merge_msg_timestamp(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_sync_routes_request/3}). -merge_msg_sync_routes_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_start_domain_request/3}). -merge_msg_start_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). -merge_msg_stop_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{force := NFforce}} -> S3#{force => NFforce}; - {#{force := PFforce}, _} -> S3#{force => PFforce}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_get_domain_request/3}). -merge_msg_get_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_domain/3}). -merge_msg_domain(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S3#{name => NFname}; - {#{name := PFname}, _} -> S3#{name => PFname}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; - {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; - {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; - _ -> S6 - end, - S8 = case {PMsg, NMsg} of - {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; - {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; - _ -> S7 - end, - S9 = case {PMsg, NMsg} of - {_, #{state := NFstate}} -> S8#{state => NFstate}; - {#{state := PFstate}, _} -> S8#{state => PFstate}; - _ -> S8 - end, - S10 = case {PMsg, NMsg} of - {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; - {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; - _ -> S9 - end, - S11 = case {PMsg, NMsg} of - {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; - {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; - _ -> S10 - end, - S12 = case {PMsg, NMsg} of - {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; - {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; - _ -> S11 - end, - S13 = case {PMsg, NMsg} of - {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; - {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; - _ -> S12 - end, - S14 = case {PMsg, NMsg} of - {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; - {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; - _ -> S13 - end, - S15 = case {PMsg, NMsg} of - {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; - {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; - {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; - {_, _} -> S14 - end, - case {PMsg, NMsg} of - {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; - {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; - _ -> S15 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_request/3}). -merge_msg_list_domains_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_response/3}). -merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; - {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; - {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_domain_request/3}). -merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; - {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; - {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). -merge_msg_delete_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_download_image_request/3}). -merge_msg_download_image_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_image_chunk/3}). -merge_msg_image_chunk(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; - {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_get_network_request/3}). -merge_msg_get_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_network/3}). -merge_msg_network(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; - {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; - {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_request/3}). -merge_msg_list_networks_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_response/3}). -merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; - {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; - {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_network_request/3}). -merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; - {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_network_request/3}). -merge_msg_delete_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_get_volume_request/3}). -merge_msg_get_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume/3}). -merge_msg_volume(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{size := NFsize}} -> S3#{size => NFsize}; - {#{size := PFsize}, _} -> S3#{size => PFsize}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). -merge_msg_list_volumes_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). -merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; - {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; - {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_volume_request/3}). -merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_update_volume_request/3}). -merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). -merge_msg_delete_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). -merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S3#{host => NFhost}; - {#{host := PFhost}, _} -> S3#{host => PFhost}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment/3}). -merge_msg_volume_attachment(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; - {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). -merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). -merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; - {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; - {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). -merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding/3}). -merge_msg_port_forwarding(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; - {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; - {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). -merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). -merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; - {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; - {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). -merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; - {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; - {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_dns_record_identifier/3}). -merge_msg_dns_record_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S2#{type => NFtype}; - {#{type := PFtype}, _} -> S2#{type => PFtype}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_dns_record/3}). -merge_msg_dns_record(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S2#{type => NFtype}; - {#{type := PFtype}, _} -> S2#{type => PFtype}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{ttl := NFttl}} -> S3#{ttl => NFttl}; - {#{ttl := PFttl}, _} -> S3#{ttl => PFttl}; - _ -> S3 - end, - case {PMsg, NMsg} of - {#{records := PFrecords}, #{records := NFrecords}} -> S4#{records => 'erlang_++'(PFrecords, NFrecords, TrUserData)}; - {_, #{records := NFrecords}} -> S4#{records => NFrecords}; - {#{records := PFrecords}, _} -> S4#{records => PFrecords}; - {_, _} -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_dns_records_request/3}). -merge_msg_list_dns_records_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_list_dns_records_response/3}). -merge_msg_list_dns_records_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{dns_records := PFdns_records}, #{dns_records := NFdns_records}} -> S1#{dns_records => 'erlang_++'(PFdns_records, NFdns_records, TrUserData)}; - {_, #{dns_records := NFdns_records}} -> S1#{dns_records => NFdns_records}; - {#{dns_records := PFdns_records}, _} -> S1#{dns_records => PFdns_records}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_dns_record_request/3}). -merge_msg_put_dns_record_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{dns_record := PFdns_record}, #{dns_record := NFdns_record}} -> S1#{dns_record => merge_msg_dns_record(PFdns_record, NFdns_record, TrUserData)}; - {_, #{dns_record := NFdns_record}} -> S1#{dns_record => NFdns_record}; - {#{dns_record := PFdns_record}, _} -> S1#{dns_record => PFdns_record}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_route_table/3}). -merge_msg_route_table(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; - {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S2#{id => NFid}; - {#{id := PFid}, _} -> S2#{id => PFid}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{name := NFname}} -> S3#{name => NFname}; - {#{name := PFname}, _} -> S3#{name => PFname}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_route_table_identifier/3}). -merge_msg_route_table_identifier(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_route_tables_request/3}). -merge_msg_list_route_tables_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; - {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_route_tables_response/3}). -merge_msg_list_route_tables_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route_tables := PFroute_tables}, #{route_tables := NFroute_tables}} -> S1#{route_tables => 'erlang_++'(PFroute_tables, NFroute_tables, TrUserData)}; - {_, #{route_tables := NFroute_tables}} -> S1#{route_tables => NFroute_tables}; - {#{route_tables := PFroute_tables}, _} -> S1#{route_tables => PFroute_tables}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_route_table_request/3}). -merge_msg_create_route_table_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route_table := PFroute_table}, #{route_table := NFroute_table}} -> S1#{route_table => merge_msg_route_table(PFroute_table, NFroute_table, TrUserData)}; - {_, #{route_table := NFroute_table}} -> S1#{route_table => NFroute_table}; - {#{route_table := PFroute_table}, _} -> S1#{route_table => PFroute_table}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_route_identifier/3}). -merge_msg_route_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; - {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_route/3}). -merge_msg_route(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; - {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; - _ -> S2 - end, - case {PMsg, NMsg} of - {#{gateways := PFgateways}, #{gateways := NFgateways}} -> S3#{gateways => 'erlang_++'(PFgateways, NFgateways, TrUserData)}; - {_, #{gateways := NFgateways}} -> S3#{gateways => NFgateways}; - {#{gateways := PFgateways}, _} -> S3#{gateways => PFgateways}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_routes_request/3}). -merge_msg_list_routes_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_routes_response/3}). -merge_msg_list_routes_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{routes := PFroutes}, #{routes := NFroutes}} -> S1#{routes => 'erlang_++'(PFroutes, NFroutes, TrUserData)}; - {_, #{routes := NFroutes}} -> S1#{routes => NFroutes}; - {#{routes := PFroutes}, _} -> S1#{routes => PFroutes}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_route_request/3}). -merge_msg_put_route_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route := PFroute}, #{route := NFroute}} -> S1#{route => merge_msg_route(PFroute, NFroute, TrUserData)}; - {_, #{route := NFroute}} -> S1#{route => NFroute}; - {#{route := PFroute}, _} -> S1#{route => PFroute}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_sync_request/3}). -merge_msg_sync_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_timestamp/3}). -merge_msg_timestamp(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; - {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; - {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; - _ -> S2 - end. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - sync_routes_request -> v_msg_sync_routes_request(Msg, [MsgName], TrUserData); - start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); - stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); - get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); - domain -> v_msg_domain(Msg, [MsgName], TrUserData); - list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); - list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); - create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); - delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); - download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); - image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); - get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); - network -> v_msg_network(Msg, [MsgName], TrUserData); - list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); - list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); - create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); - delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); - get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); - volume -> v_msg_volume(Msg, [MsgName], TrUserData); - list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); - list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); - create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); - update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); - delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); - volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); - volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); - list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); - list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); - port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); - port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); - list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); - list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); - put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); - dns_record_identifier -> v_msg_dns_record_identifier(Msg, [MsgName], TrUserData); - dns_record -> v_msg_dns_record(Msg, [MsgName], TrUserData); - list_dns_records_request -> v_msg_list_dns_records_request(Msg, [MsgName], TrUserData); - list_dns_records_response -> v_msg_list_dns_records_response(Msg, [MsgName], TrUserData); - put_dns_record_request -> v_msg_put_dns_record_request(Msg, [MsgName], TrUserData); - route_table -> v_msg_route_table(Msg, [MsgName], TrUserData); - route_table_identifier -> v_msg_route_table_identifier(Msg, [MsgName], TrUserData); - list_route_tables_request -> v_msg_list_route_tables_request(Msg, [MsgName], TrUserData); - list_route_tables_response -> v_msg_list_route_tables_response(Msg, [MsgName], TrUserData); - create_route_table_request -> v_msg_create_route_table_request(Msg, [MsgName], TrUserData); - route_identifier -> v_msg_route_identifier(Msg, [MsgName], TrUserData); - route -> v_msg_route(Msg, [MsgName], TrUserData); - list_routes_request -> v_msg_list_routes_request(Msg, [MsgName], TrUserData); - list_routes_response -> v_msg_list_routes_response(Msg, [MsgName], TrUserData); - put_route_request -> v_msg_put_route_request(Msg, [MsgName], TrUserData); - sync_request -> v_msg_sync_request(Msg, [MsgName], TrUserData); - timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_msg_sync_routes_request/3}). --dialyzer({nowarn_function,v_msg_sync_routes_request/3}). -v_msg_sync_routes_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_sync_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_routes_request}, M, Path); -v_msg_sync_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_routes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_start_domain_request/3}). --dialyzer({nowarn_function,v_msg_start_domain_request/3}). -v_msg_start_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); -v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_stop_domain_request/3}). --dialyzer({nowarn_function,v_msg_stop_domain_request/3}). -v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (force) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); -v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_get_domain_request/3}). --dialyzer({nowarn_function,v_msg_get_domain_request/3}). -v_msg_get_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); -v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_domain/3}). --dialyzer({nowarn_function,v_msg_domain/3}). -v_msg_domain(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); - _ -> ok - end, - case M of - #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); - _ -> ok - end, - case M of - #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); - _ -> ok - end, - case M of - #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); - _ -> ok - end, - case M of - #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); - _ -> ok - end, - case M of - #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); - _ -> ok - end, - case M of - #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); - _ -> ok - end, - case M of - #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); - _ -> ok - end, - case M of - #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); - _ -> ok - end, - case M of - #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (uuid) -> ok; - (name) -> ok; - (vcpu) -> ok; - (memory) -> ok; - (network) -> ok; - (bridge) -> ok; - (state) -> ok; - (private_ip) -> ok; - (ipv6_address) -> ok; - (user_data) -> ok; - (nested_virtualization) -> ok; - (base_image) -> ok; - (created_at) -> ok; - (os_type) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); -v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_request/3}). --dialyzer({nowarn_function,v_msg_list_domains_request/3}). -v_msg_list_domains_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); -v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_response/3}). --dialyzer({nowarn_function,v_msg_list_domains_response/3}). -v_msg_list_domains_response(#{} = M, Path, TrUserData) -> - case M of - #{domains := F1} -> - if is_list(F1) -> - _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) - end; - _ -> ok - end, - lists:foreach(fun (domains) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); -v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_domain_request/3}). --dialyzer({nowarn_function,v_msg_create_domain_request/3}). -v_msg_create_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); -v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_domain_request/3}). --dialyzer({nowarn_function,v_msg_delete_domain_request/3}). -v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); -v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_download_image_request/3}). --dialyzer({nowarn_function,v_msg_download_image_request/3}). -v_msg_download_image_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); -v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). - --compile({nowarn_unused_function,v_msg_image_chunk/3}). --dialyzer({nowarn_function,v_msg_image_chunk/3}). -v_msg_image_chunk(#{} = M, Path, TrUserData) -> - case M of - #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (bytes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); -v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). - --compile({nowarn_unused_function,v_msg_get_network_request/3}). --dialyzer({nowarn_function,v_msg_get_network_request/3}). -v_msg_get_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); -v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_network/3}). --dialyzer({nowarn_function,v_msg_network/3}). -v_msg_network(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (name) -> ok; - (cidr) -> ok; - (cidr6) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); -v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_request/3}). --dialyzer({nowarn_function,v_msg_list_networks_request/3}). -v_msg_list_networks_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); -v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_response/3}). --dialyzer({nowarn_function,v_msg_list_networks_response/3}). -v_msg_list_networks_response(#{} = M, Path, TrUserData) -> - case M of - #{networks := F1} -> - if is_list(F1) -> - _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) - end; - _ -> ok - end, - lists:foreach(fun (networks) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); -v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_network_request/3}). --dialyzer({nowarn_function,v_msg_create_network_request/3}). -v_msg_create_network_request(#{} = M, Path, TrUserData) -> - case M of - #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); -v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_network_request/3}). --dialyzer({nowarn_function,v_msg_delete_network_request/3}). -v_msg_delete_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); -v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_get_volume_request/3}). --dialyzer({nowarn_function,v_msg_get_volume_request/3}). -v_msg_get_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); -v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume/3}). --dialyzer({nowarn_function,v_msg_volume/3}). -v_msg_volume(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (name) -> ok; - (size) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); -v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_request/3}). --dialyzer({nowarn_function,v_msg_list_volumes_request/3}). -v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); -v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_response/3}). --dialyzer({nowarn_function,v_msg_list_volumes_response/3}). -v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> - case M of - #{volumes := F1} -> - if is_list(F1) -> - _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) - end; - _ -> ok - end, - lists:foreach(fun (volumes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); -v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_volume_request/3}). --dialyzer({nowarn_function,v_msg_create_volume_request/3}). -v_msg_create_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (volume) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); -v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_update_volume_request/3}). --dialyzer({nowarn_function,v_msg_update_volume_request/3}). -v_msg_update_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (volume) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); -v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_volume_request/3}). --dialyzer({nowarn_function,v_msg_delete_volume_request/3}). -v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); -v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). --dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). -v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); -v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment/3}). --dialyzer({nowarn_function,v_msg_volume_attachment/3}). -v_msg_volume_attachment(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (disk_address) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); -v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). -v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); -v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). -v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> - case M of - #{attachments := F1} -> - if is_list(F1) -> - _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) - end; - _ -> ok - end, - lists:foreach(fun (attachments) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); -v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). - --compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). --dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). -v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (protocol) -> ok; - (source_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); -v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_port_forwarding/3}). --dialyzer({nowarn_function,v_msg_port_forwarding/3}). -v_msg_port_forwarding(#{} = M, Path, TrUserData) -> - case M of - #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); - _ -> ok - end, - case M of - #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (protocol) -> ok; - (source_port) -> ok; - (target_ip) -> ok; - (target_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); -v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). -v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); -v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). -v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> - case M of - #{port_forwardings := F1} -> - if is_list(F1) -> - _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) - end; - _ -> ok - end, - lists:foreach(fun (port_forwardings) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); -v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). --dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). -v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> - case M of - #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (port_forwarding) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); -v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). - --compile({nowarn_unused_function,v_msg_dns_record_identifier/3}). --dialyzer({nowarn_function,v_msg_dns_record_identifier/3}). -v_msg_dns_record_identifier(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (type) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_dns_record_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record_identifier}, M, Path); -v_msg_dns_record_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_dns_record/3}). --dialyzer({nowarn_function,v_msg_dns_record/3}). -v_msg_dns_record(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); - _ -> ok - end, - case M of - #{ttl := F3} -> v_type_uint64(F3, [ttl | Path], TrUserData); - _ -> ok - end, - case M of - #{records := F4} -> - if is_list(F4) -> - _ = [v_type_string(Elem, [records | Path], TrUserData) || Elem <- F4], - ok; - true -> mk_type_error({invalid_list_of, string}, F4, [records | Path]) - end; - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (type) -> ok; - (ttl) -> ok; - (records) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_dns_record(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record}, M, Path); -v_msg_dns_record(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record}, X, Path). - --compile({nowarn_unused_function,v_msg_list_dns_records_request/3}). --dialyzer({nowarn_function,v_msg_list_dns_records_request/3}). -v_msg_list_dns_records_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_list_dns_records_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_request}, M, Path); -v_msg_list_dns_records_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_dns_records_response/3}). --dialyzer({nowarn_function,v_msg_list_dns_records_response/3}). -v_msg_list_dns_records_response(#{} = M, Path, TrUserData) -> - case M of - #{dns_records := F1} -> - if is_list(F1) -> - _ = [v_msg_dns_record(Elem, [dns_records | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, dns_record}}, F1, [dns_records | Path]) - end; - _ -> ok - end, - lists:foreach(fun (dns_records) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_dns_records_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_response}, M, Path); -v_msg_list_dns_records_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_dns_record_request/3}). --dialyzer({nowarn_function,v_msg_put_dns_record_request/3}). -v_msg_put_dns_record_request(#{} = M, Path, TrUserData) -> - case M of - #{dns_record := F1} -> v_msg_dns_record(F1, [dns_record | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (dns_record) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_dns_record_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_dns_record_request}, M, Path); -v_msg_put_dns_record_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_dns_record_request}, X, Path). - --compile({nowarn_unused_function,v_msg_route_table/3}). --dialyzer({nowarn_function,v_msg_route_table/3}). -v_msg_route_table(#{} = M, Path, TrUserData) -> - case M of - #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); - _ -> ok - end, - case M of - #{id := F2} -> v_type_uint32(F2, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network_name) -> ok; - (id) -> ok; - (name) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_table(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table}, M, Path); -v_msg_route_table(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table}, X, Path). - --compile({nowarn_unused_function,v_msg_route_table_identifier/3}). --dialyzer({nowarn_function,v_msg_route_table_identifier/3}). -v_msg_route_table_identifier(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_uint32(F1, [id | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_table_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table_identifier}, M, Path); -v_msg_route_table_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_list_route_tables_request/3}). --dialyzer({nowarn_function,v_msg_list_route_tables_request/3}). -v_msg_list_route_tables_request(#{} = M, Path, TrUserData) -> - case M of - #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network_name) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_route_tables_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_request}, M, Path); -v_msg_list_route_tables_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_route_tables_response/3}). --dialyzer({nowarn_function,v_msg_list_route_tables_response/3}). -v_msg_list_route_tables_response(#{} = M, Path, TrUserData) -> - case M of - #{route_tables := F1} -> - if is_list(F1) -> - _ = [v_msg_route_table(Elem, [route_tables | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, route_table}}, F1, [route_tables | Path]) - end; - _ -> ok - end, - lists:foreach(fun (route_tables) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_route_tables_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_response}, M, Path); -v_msg_list_route_tables_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_route_table_request/3}). --dialyzer({nowarn_function,v_msg_create_route_table_request/3}). -v_msg_create_route_table_request(#{} = M, Path, TrUserData) -> - case M of - #{route_table := F1} -> v_msg_route_table(F1, [route_table | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_route_table_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_route_table_request}, M, Path); -v_msg_create_route_table_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_route_table_request}, X, Path). - --compile({nowarn_unused_function,v_msg_route_identifier/3}). --dialyzer({nowarn_function,v_msg_route_identifier/3}). -v_msg_route_identifier(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - case M of - #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (destination) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_identifier}, M, Path); -v_msg_route_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_route/3}). --dialyzer({nowarn_function,v_msg_route/3}). -v_msg_route(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - case M of - #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); - _ -> ok - end, - case M of - #{gateways := F3} -> - if is_list(F3) -> - _ = [v_type_string(Elem, [gateways | Path], TrUserData) || Elem <- F3], - ok; - true -> mk_type_error({invalid_list_of, string}, F3, [gateways | Path]) - end; - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (destination) -> ok; - (gateways) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route}, M, Path); -v_msg_route(X, Path, _TrUserData) -> mk_type_error({expected_msg, route}, X, Path). - --compile({nowarn_unused_function,v_msg_list_routes_request/3}). --dialyzer({nowarn_function,v_msg_list_routes_request/3}). -v_msg_list_routes_request(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_request}, M, Path); -v_msg_list_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_routes_response/3}). --dialyzer({nowarn_function,v_msg_list_routes_response/3}). -v_msg_list_routes_response(#{} = M, Path, TrUserData) -> - case M of - #{routes := F1} -> - if is_list(F1) -> - _ = [v_msg_route(Elem, [routes | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, route}}, F1, [routes | Path]) - end; - _ -> ok - end, - lists:foreach(fun (routes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_routes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_response}, M, Path); -v_msg_list_routes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_route_request/3}). --dialyzer({nowarn_function,v_msg_put_route_request/3}). -v_msg_put_route_request(#{} = M, Path, TrUserData) -> - case M of - #{route := F1} -> v_msg_route(F1, [route | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_route_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_route_request}, M, Path); -v_msg_put_route_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_route_request}, X, Path). - --compile({nowarn_unused_function,v_msg_sync_request/3}). --dialyzer({nowarn_function,v_msg_sync_request/3}). -v_msg_sync_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_sync_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_request}, M, Path); -v_msg_sync_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_request}, X, Path). - --compile({nowarn_unused_function,v_msg_timestamp/3}). --dialyzer({nowarn_function,v_msg_timestamp/3}). -v_msg_timestamp(#{} = M, Path, TrUserData) -> - case M of - #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); - _ -> ok - end, - case M of - #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (seconds) -> ok; - (nanos) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); -v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). - --compile({nowarn_unused_function,v_type_int32/3}). --dialyzer({nowarn_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; -v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); -v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). - --compile({nowarn_unused_function,v_type_int64/3}). --dialyzer({nowarn_function,v_type_int64/3}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; -v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); -v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; -v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); -v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; -v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); -v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). - --compile({nowarn_unused_function,v_type_bool/3}). --dialyzer({nowarn_function,v_type_bool/3}). -v_type_bool(false, _Path, _TrUserData) -> ok; -v_type_bool(true, _Path, _TrUserData) -> ok; -v_type_bool(0, _Path, _TrUserData) -> ok; -v_type_bool(1, _Path, _TrUserData) -> ok; -v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,v_type_bytes/3}). --dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; -v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, empty}, []}, - {{msg, sync_routes_request}, []}, - {{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, stop_domain_request}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, - {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, domain}, - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, - {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, - {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, network}, - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, - {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume}, - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, - {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, - {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, - {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment_identifier}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, - {{msg, port_forwarding_identifier}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, - {{msg, port_forwarding}, - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, - {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, dns_record_identifier}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, dns_record}, - [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, - #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]}, - {{msg, list_dns_records_request}, []}, - {{msg, list_dns_records_response}, [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]}, - {{msg, put_dns_record_request}, [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]}, - {{msg, route_table}, - [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, route_table_identifier}, [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_route_tables_request}, [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_route_tables_response}, [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]}, - {{msg, create_route_table_request}, [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]}, - {{msg, route_identifier}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, route}, - [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, - #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]}, - {{msg, list_routes_request}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_routes_response}, [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]}, - {{msg, put_route_request}, [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]}, - {{msg, sync_request}, []}, - {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. - - -get_msg_names() -> - [empty, - sync_routes_request, - start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - port_forwarding_identifier, - port_forwarding, - list_port_forwardings_request, - list_port_forwardings_response, - put_port_forwarding_request, - dns_record_identifier, - dns_record, - list_dns_records_request, - list_dns_records_response, - put_dns_record_request, - route_table, - route_table_identifier, - list_route_tables_request, - list_route_tables_response, - create_route_table_request, - route_identifier, - route, - list_routes_request, - list_routes_response, - put_route_request, - sync_request, - timestamp]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [empty, - sync_routes_request, - start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - port_forwarding_identifier, - port_forwarding, - list_port_forwardings_request, - list_port_forwardings_response, - put_port_forwarding_request, - dns_record_identifier, - dns_record, - list_dns_records_request, - list_dns_records_response, - put_dns_record_request, - route_table, - route_table_identifier, - list_route_tables_request, - list_route_tables_response, - create_route_table_request, - route_identifier, - route, - list_routes_request, - list_routes_response, - put_route_request, - sync_request, - timestamp]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(empty) -> []; -find_msg_def(sync_routes_request) -> []; -find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(stop_domain_request) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; -find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(domain) -> - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; -find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; -find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(network) -> - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; -find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume) -> - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; -find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; -find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment_identifier) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; -find_msg_def(port_forwarding_identifier) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(port_forwarding) -> - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; -find_msg_def(put_port_forwarding_request) -> - [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(dns_record_identifier) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(dns_record) -> - [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, - #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]; -find_msg_def(list_dns_records_request) -> []; -find_msg_def(list_dns_records_response) -> [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]; -find_msg_def(put_dns_record_request) -> [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]; -find_msg_def(route_table) -> - [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(route_table_identifier) -> [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_route_tables_request) -> [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_route_tables_response) -> [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]; -find_msg_def(create_route_table_request) -> [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]; -find_msg_def(route_identifier) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(route) -> - [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, - #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]; -find_msg_def(list_routes_request) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_routes_response) -> [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]; -find_msg_def(put_route_request) -> [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]; -find_msg_def(sync_request) -> []; -find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['ControllerService', 'DaemonService', 'DomainService', 'VolumeService', 'PortForwardingService', 'DNS', 'RouteService']. - - -get_service_def('ControllerService') -> - {{service, 'ControllerService'}, - [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('DaemonService') -> - {{service, 'DaemonService'}, - [#{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('DomainService') -> - {{service, 'DomainService'}, - [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('VolumeService') -> - {{service, 'VolumeService'}, - [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('PortForwardingService') -> - {{service, 'PortForwardingService'}, - [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('DNS') -> - {{service, 'DNS'}, - [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('RouteService') -> - {{service, 'RouteService'}, - [#{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('ControllerService') -> - ['GetDNSRecord', - 'ListDNSRecords', - 'PutDNSRecord', - 'DeleteDNSRecord', - 'GetNetwork', - 'ListNetworks', - 'CreateNetwork', - 'DeleteNetwork', - 'StartDomain', - 'StopDomain', - 'GetDomain', - 'ListDomains', - 'CreateDomain', - 'DeleteDomain', - 'DownloadImage', - 'GetVolume', - 'ListVolumes', - 'CreateVolume', - 'UpdateVolume', - 'DeleteVolume', - 'ListVolumeAttachments', - 'GetVolumeAttachment', - 'AttachVolume', - 'DetachVolume', - 'GetPortForwarding', - 'ListPortForwardings', - 'PutPortForwarding', - 'DeletePortForwarding', - 'GetRouteTable', - 'ListRouteTables', - 'CreateRouteTable', - 'DeleteRouteTable', - 'GetRoute', - 'ListRoutes', - 'PutRoute', - 'DeleteRoute', - 'SyncRoutes']; -get_rpc_names('DaemonService') -> - ['GetNetwork', - 'ListNetworks', - 'CreateNetwork', - 'DeleteNetwork', - 'StartDomain', - 'StopDomain', - 'GetDomain', - 'ListDomains', - 'CreateDomain', - 'DeleteDomain', - 'DownloadImage', - 'GetVolume', - 'ListVolumes', - 'CreateVolume', - 'UpdateVolume', - 'DeleteVolume', - 'ListVolumeAttachments', - 'GetVolumeAttachment', - 'AttachVolume', - 'DetachVolume', - 'GetPortForwarding', - 'ListPortForwardings', - 'PutPortForwarding', - 'DeletePortForwarding', - 'SyncRoutes']; -get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; -get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; -get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; -get_rpc_names('DNS') -> ['GetDNSRecord', 'ListDNSRecords', 'PutDNSRecord', 'DeleteDNSRecord']; -get_rpc_names('RouteService') -> ['GetRouteTable', 'ListRouteTables', 'CreateRouteTable', 'DeleteRouteTable', 'GetRoute', 'ListRoutes', 'PutRoute', 'DeleteRoute', 'Sync']; -get_rpc_names(_) -> error. - - -find_rpc_def('ControllerService', RpcName) -> find_rpc_def_ControllerService(RpcName); -find_rpc_def('DaemonService', RpcName) -> find_rpc_def_DaemonService(RpcName); -find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); -find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); -find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); -find_rpc_def('DNS', RpcName) -> find_rpc_def_DNS(RpcName); -find_rpc_def('RouteService', RpcName) -> find_rpc_def_RouteService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_ControllerService('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_ControllerService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_ControllerService(_) -> error. - -find_rpc_def_DaemonService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_DaemonService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService(_) -> error. - -find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService(_) -> error. - -find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService(_) -> error. - -find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService(_) -> error. - -find_rpc_def_DNS('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS(_) -> error. - -find_rpc_def_RouteService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('Sync') -> #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"ControllerService">>) -> 'ControllerService'; -fqbin_to_service_name(<<"DaemonService">>) -> 'DaemonService'; -fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; -fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; -fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; -fqbin_to_service_name(<<"DNS">>) -> 'DNS'; -fqbin_to_service_name(<<"RouteService">>) -> 'RouteService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('ControllerService') -> <<"ControllerService">>; -service_name_to_fqbin('DaemonService') -> <<"DaemonService">>; -service_name_to_fqbin('DomainService') -> <<"DomainService">>; -service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; -service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; -service_name_to_fqbin('DNS') -> <<"DNS">>; -service_name_to_fqbin('RouteService') -> <<"RouteService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetDNSRecord">>) -> {'ControllerService', 'GetDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListDNSRecords">>) -> {'ControllerService', 'ListDNSRecords'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutDNSRecord">>) -> {'ControllerService', 'PutDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteDNSRecord">>) -> {'ControllerService', 'DeleteDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetNetwork">>) -> {'ControllerService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListNetworks">>) -> {'ControllerService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateNetwork">>) -> {'ControllerService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteNetwork">>) -> {'ControllerService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"StartDomain">>) -> {'ControllerService', 'StartDomain'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"StopDomain">>) -> {'ControllerService', 'StopDomain'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetDomain">>) -> {'ControllerService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListDomains">>) -> {'ControllerService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateDomain">>) -> {'ControllerService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteDomain">>) -> {'ControllerService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DownloadImage">>) -> {'ControllerService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetVolume">>) -> {'ControllerService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListVolumes">>) -> {'ControllerService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateVolume">>) -> {'ControllerService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"UpdateVolume">>) -> {'ControllerService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteVolume">>) -> {'ControllerService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListVolumeAttachments">>) -> {'ControllerService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetVolumeAttachment">>) -> {'ControllerService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"AttachVolume">>) -> {'ControllerService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DetachVolume">>) -> {'ControllerService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetPortForwarding">>) -> {'ControllerService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListPortForwardings">>) -> {'ControllerService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutPortForwarding">>) -> {'ControllerService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeletePortForwarding">>) -> {'ControllerService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetRouteTable">>) -> {'ControllerService', 'GetRouteTable'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListRouteTables">>) -> {'ControllerService', 'ListRouteTables'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"CreateRouteTable">>) -> {'ControllerService', 'CreateRouteTable'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteRouteTable">>) -> {'ControllerService', 'DeleteRouteTable'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"GetRoute">>) -> {'ControllerService', 'GetRoute'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"ListRoutes">>) -> {'ControllerService', 'ListRoutes'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"PutRoute">>) -> {'ControllerService', 'PutRoute'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"DeleteRoute">>) -> {'ControllerService', 'DeleteRoute'}; -fqbins_to_service_and_rpc_name(<<"ControllerService">>, <<"SyncRoutes">>) -> {'ControllerService', 'SyncRoutes'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetNetwork">>) -> {'DaemonService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListNetworks">>) -> {'DaemonService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateNetwork">>) -> {'DaemonService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteNetwork">>) -> {'DaemonService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StartDomain">>) -> {'DaemonService', 'StartDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StopDomain">>) -> {'DaemonService', 'StopDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetDomain">>) -> {'DaemonService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListDomains">>) -> {'DaemonService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateDomain">>) -> {'DaemonService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteDomain">>) -> {'DaemonService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DownloadImage">>) -> {'DaemonService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolume">>) -> {'DaemonService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumes">>) -> {'DaemonService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateVolume">>) -> {'DaemonService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"UpdateVolume">>) -> {'DaemonService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteVolume">>) -> {'DaemonService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumeAttachments">>) -> {'DaemonService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolumeAttachment">>) -> {'DaemonService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"AttachVolume">>) -> {'DaemonService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DetachVolume">>) -> {'DaemonService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetPortForwarding">>) -> {'DaemonService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListPortForwardings">>) -> {'DaemonService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"PutPortForwarding">>) -> {'DaemonService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeletePortForwarding">>) -> {'DaemonService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"SyncRoutes">>) -> {'DaemonService', 'SyncRoutes'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"GetDNSRecord">>) -> {'DNS', 'GetDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"ListDNSRecords">>) -> {'DNS', 'ListDNSRecords'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"PutDNSRecord">>) -> {'DNS', 'PutDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"DeleteDNSRecord">>) -> {'DNS', 'DeleteDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRouteTable">>) -> {'RouteService', 'GetRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRouteTables">>) -> {'RouteService', 'ListRouteTables'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"CreateRouteTable">>) -> {'RouteService', 'CreateRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRouteTable">>) -> {'RouteService', 'DeleteRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRoute">>) -> {'RouteService', 'GetRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRoutes">>) -> {'RouteService', 'ListRoutes'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"PutRoute">>) -> {'RouteService', 'PutRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRoute">>) -> {'RouteService', 'DeleteRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"Sync">>) -> {'RouteService', 'Sync'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('ControllerService', 'GetDNSRecord') -> {<<"ControllerService">>, <<"GetDNSRecord">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListDNSRecords') -> {<<"ControllerService">>, <<"ListDNSRecords">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'PutDNSRecord') -> {<<"ControllerService">>, <<"PutDNSRecord">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteDNSRecord') -> {<<"ControllerService">>, <<"DeleteDNSRecord">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetNetwork') -> {<<"ControllerService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListNetworks') -> {<<"ControllerService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'CreateNetwork') -> {<<"ControllerService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteNetwork') -> {<<"ControllerService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'StartDomain') -> {<<"ControllerService">>, <<"StartDomain">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'StopDomain') -> {<<"ControllerService">>, <<"StopDomain">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetDomain') -> {<<"ControllerService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListDomains') -> {<<"ControllerService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'CreateDomain') -> {<<"ControllerService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteDomain') -> {<<"ControllerService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DownloadImage') -> {<<"ControllerService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetVolume') -> {<<"ControllerService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListVolumes') -> {<<"ControllerService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'CreateVolume') -> {<<"ControllerService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'UpdateVolume') -> {<<"ControllerService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteVolume') -> {<<"ControllerService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListVolumeAttachments') -> {<<"ControllerService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetVolumeAttachment') -> {<<"ControllerService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'AttachVolume') -> {<<"ControllerService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DetachVolume') -> {<<"ControllerService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetPortForwarding') -> {<<"ControllerService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListPortForwardings') -> {<<"ControllerService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'PutPortForwarding') -> {<<"ControllerService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeletePortForwarding') -> {<<"ControllerService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetRouteTable') -> {<<"ControllerService">>, <<"GetRouteTable">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListRouteTables') -> {<<"ControllerService">>, <<"ListRouteTables">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'CreateRouteTable') -> {<<"ControllerService">>, <<"CreateRouteTable">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteRouteTable') -> {<<"ControllerService">>, <<"DeleteRouteTable">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'GetRoute') -> {<<"ControllerService">>, <<"GetRoute">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'ListRoutes') -> {<<"ControllerService">>, <<"ListRoutes">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'PutRoute') -> {<<"ControllerService">>, <<"PutRoute">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'DeleteRoute') -> {<<"ControllerService">>, <<"DeleteRoute">>}; -service_and_rpc_name_to_fqbins('ControllerService', 'SyncRoutes') -> {<<"ControllerService">>, <<"SyncRoutes">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetNetwork') -> {<<"DaemonService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListNetworks') -> {<<"DaemonService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateNetwork') -> {<<"DaemonService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteNetwork') -> {<<"DaemonService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'StartDomain') -> {<<"DaemonService">>, <<"StartDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'StopDomain') -> {<<"DaemonService">>, <<"StopDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetDomain') -> {<<"DaemonService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListDomains') -> {<<"DaemonService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateDomain') -> {<<"DaemonService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteDomain') -> {<<"DaemonService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DownloadImage') -> {<<"DaemonService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetVolume') -> {<<"DaemonService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumes') -> {<<"DaemonService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateVolume') -> {<<"DaemonService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'UpdateVolume') -> {<<"DaemonService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteVolume') -> {<<"DaemonService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumeAttachments') -> {<<"DaemonService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetVolumeAttachment') -> {<<"DaemonService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'AttachVolume') -> {<<"DaemonService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DetachVolume') -> {<<"DaemonService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetPortForwarding') -> {<<"DaemonService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListPortForwardings') -> {<<"DaemonService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'PutPortForwarding') -> {<<"DaemonService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeletePortForwarding') -> {<<"DaemonService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'SyncRoutes') -> {<<"DaemonService">>, <<"SyncRoutes">>}; -service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins('DNS', 'GetDNSRecord') -> {<<"DNS">>, <<"GetDNSRecord">>}; -service_and_rpc_name_to_fqbins('DNS', 'ListDNSRecords') -> {<<"DNS">>, <<"ListDNSRecords">>}; -service_and_rpc_name_to_fqbins('DNS', 'PutDNSRecord') -> {<<"DNS">>, <<"PutDNSRecord">>}; -service_and_rpc_name_to_fqbins('DNS', 'DeleteDNSRecord') -> {<<"DNS">>, <<"DeleteDNSRecord">>}; -service_and_rpc_name_to_fqbins('RouteService', 'GetRouteTable') -> {<<"RouteService">>, <<"GetRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'ListRouteTables') -> {<<"RouteService">>, <<"ListRouteTables">>}; -service_and_rpc_name_to_fqbins('RouteService', 'CreateRouteTable') -> {<<"RouteService">>, <<"CreateRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'DeleteRouteTable') -> {<<"RouteService">>, <<"DeleteRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'GetRoute') -> {<<"RouteService">>, <<"GetRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'ListRoutes') -> {<<"RouteService">>, <<"ListRoutes">>}; -service_and_rpc_name_to_fqbins('RouteService', 'PutRoute') -> {<<"RouteService">>, <<"PutRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'DeleteRoute') -> {<<"RouteService">>, <<"DeleteRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'Sync') -> {<<"RouteService">>, <<"Sync">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(<<"SyncRoutesRequest">>) -> sync_routes_request; -fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; -fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; -fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; -fqbin_to_msg_name(<<"Domain">>) -> domain; -fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; -fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; -fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; -fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; -fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; -fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; -fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; -fqbin_to_msg_name(<<"Network">>) -> network; -fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; -fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; -fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; -fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; -fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; -fqbin_to_msg_name(<<"Volume">>) -> volume; -fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; -fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; -fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; -fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; -fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; -fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; -fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; -fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; -fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; -fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; -fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; -fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; -fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; -fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; -fqbin_to_msg_name(<<"DNSRecordIdentifier">>) -> dns_record_identifier; -fqbin_to_msg_name(<<"DNSRecord">>) -> dns_record; -fqbin_to_msg_name(<<"ListDNSRecordsRequest">>) -> list_dns_records_request; -fqbin_to_msg_name(<<"ListDNSRecordsResponse">>) -> list_dns_records_response; -fqbin_to_msg_name(<<"PutDNSRecordRequest">>) -> put_dns_record_request; -fqbin_to_msg_name(<<"RouteTable">>) -> route_table; -fqbin_to_msg_name(<<"RouteTableIdentifier">>) -> route_table_identifier; -fqbin_to_msg_name(<<"ListRouteTablesRequest">>) -> list_route_tables_request; -fqbin_to_msg_name(<<"ListRouteTablesResponse">>) -> list_route_tables_response; -fqbin_to_msg_name(<<"CreateRouteTableRequest">>) -> create_route_table_request; -fqbin_to_msg_name(<<"RouteIdentifier">>) -> route_identifier; -fqbin_to_msg_name(<<"Route">>) -> route; -fqbin_to_msg_name(<<"ListRoutesRequest">>) -> list_routes_request; -fqbin_to_msg_name(<<"ListRoutesResponse">>) -> list_routes_response; -fqbin_to_msg_name(<<"PutRouteRequest">>) -> put_route_request; -fqbin_to_msg_name(<<"SyncRequest">>) -> sync_request; -fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(sync_routes_request) -> <<"SyncRoutesRequest">>; -msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; -msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; -msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; -msg_name_to_fqbin(domain) -> <<"Domain">>; -msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; -msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; -msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; -msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; -msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; -msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; -msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; -msg_name_to_fqbin(network) -> <<"Network">>; -msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; -msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; -msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; -msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; -msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; -msg_name_to_fqbin(volume) -> <<"Volume">>; -msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; -msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; -msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; -msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; -msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; -msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; -msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; -msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; -msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; -msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; -msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; -msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; -msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; -msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; -msg_name_to_fqbin(dns_record_identifier) -> <<"DNSRecordIdentifier">>; -msg_name_to_fqbin(dns_record) -> <<"DNSRecord">>; -msg_name_to_fqbin(list_dns_records_request) -> <<"ListDNSRecordsRequest">>; -msg_name_to_fqbin(list_dns_records_response) -> <<"ListDNSRecordsResponse">>; -msg_name_to_fqbin(put_dns_record_request) -> <<"PutDNSRecordRequest">>; -msg_name_to_fqbin(route_table) -> <<"RouteTable">>; -msg_name_to_fqbin(route_table_identifier) -> <<"RouteTableIdentifier">>; -msg_name_to_fqbin(list_route_tables_request) -> <<"ListRouteTablesRequest">>; -msg_name_to_fqbin(list_route_tables_response) -> <<"ListRouteTablesResponse">>; -msg_name_to_fqbin(create_route_table_request) -> <<"CreateRouteTableRequest">>; -msg_name_to_fqbin(route_identifier) -> <<"RouteIdentifier">>; -msg_name_to_fqbin(route) -> <<"Route">>; -msg_name_to_fqbin(list_routes_request) -> <<"ListRoutesRequest">>; -msg_name_to_fqbin(list_routes_response) -> <<"ListRoutesResponse">>; -msg_name_to_fqbin(put_route_request) -> <<"PutRouteRequest">>; -msg_name_to_fqbin(sync_request) -> <<"SyncRequest">>; -msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "controller.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["controller.proto", "empty.proto", "daemon.proto", "domain.proto", "volume.proto", "port_forwarding.proto", "dns.proto", "route.proto", "timestamp.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["controller", "empty", "daemon", "domain", "volume", "port_forwarding", "dns", "route", "timestamp"]. - - -get_msg_containment("controller") -> []; -get_msg_containment("empty") -> [empty]; -get_msg_containment("daemon") -> [sync_routes_request]; -get_msg_containment("domain") -> - [create_domain_request, - create_network_request, - delete_domain_request, - delete_network_request, - domain, - download_image_request, - get_domain_request, - get_network_request, - image_chunk, - list_domains_request, - list_domains_response, - list_networks_request, - list_networks_response, - network, - start_domain_request, - stop_domain_request]; -get_msg_containment("volume") -> - [create_volume_request, - delete_volume_request, - get_volume_request, - list_volume_attachments_request, - list_volume_attachments_response, - list_volumes_request, - list_volumes_response, - update_volume_request, - volume, - volume_attachment, - volume_attachment_identifier]; -get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; -get_msg_containment("dns") -> [dns_record, dns_record_identifier, list_dns_records_request, list_dns_records_response, put_dns_record_request]; -get_msg_containment("route") -> - [create_route_table_request, list_route_tables_request, list_route_tables_response, list_routes_request, list_routes_response, put_route_request, route, route_identifier, route_table, route_table_identifier, sync_request]; -get_msg_containment("timestamp") -> [timestamp]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("controller") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment("daemon") -> undefined; -get_pkg_containment("domain") -> undefined; -get_pkg_containment("volume") -> undefined; -get_pkg_containment("port_forwarding") -> undefined; -get_pkg_containment("dns") -> undefined; -get_pkg_containment("route") -> undefined; -get_pkg_containment("timestamp") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("controller") -> ['ControllerService']; -get_service_containment("empty") -> []; -get_service_containment("daemon") -> ['DaemonService']; -get_service_containment("domain") -> ['DomainService']; -get_service_containment("volume") -> ['VolumeService']; -get_service_containment("port_forwarding") -> ['PortForwardingService']; -get_service_containment("dns") -> ['DNS']; -get_service_containment("route") -> ['RouteService']; -get_service_containment("timestamp") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("controller") -> - [{'ControllerService', 'GetDNSRecord'}, - {'ControllerService', 'ListDNSRecords'}, - {'ControllerService', 'PutDNSRecord'}, - {'ControllerService', 'DeleteDNSRecord'}, - {'ControllerService', 'GetNetwork'}, - {'ControllerService', 'ListNetworks'}, - {'ControllerService', 'CreateNetwork'}, - {'ControllerService', 'DeleteNetwork'}, - {'ControllerService', 'StartDomain'}, - {'ControllerService', 'StopDomain'}, - {'ControllerService', 'GetDomain'}, - {'ControllerService', 'ListDomains'}, - {'ControllerService', 'CreateDomain'}, - {'ControllerService', 'DeleteDomain'}, - {'ControllerService', 'DownloadImage'}, - {'ControllerService', 'GetVolume'}, - {'ControllerService', 'ListVolumes'}, - {'ControllerService', 'CreateVolume'}, - {'ControllerService', 'UpdateVolume'}, - {'ControllerService', 'DeleteVolume'}, - {'ControllerService', 'ListVolumeAttachments'}, - {'ControllerService', 'GetVolumeAttachment'}, - {'ControllerService', 'AttachVolume'}, - {'ControllerService', 'DetachVolume'}, - {'ControllerService', 'GetPortForwarding'}, - {'ControllerService', 'ListPortForwardings'}, - {'ControllerService', 'PutPortForwarding'}, - {'ControllerService', 'DeletePortForwarding'}, - {'ControllerService', 'GetRouteTable'}, - {'ControllerService', 'ListRouteTables'}, - {'ControllerService', 'CreateRouteTable'}, - {'ControllerService', 'DeleteRouteTable'}, - {'ControllerService', 'GetRoute'}, - {'ControllerService', 'ListRoutes'}, - {'ControllerService', 'PutRoute'}, - {'ControllerService', 'DeleteRoute'}, - {'ControllerService', 'SyncRoutes'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment("daemon") -> - [{'DaemonService', 'GetNetwork'}, - {'DaemonService', 'ListNetworks'}, - {'DaemonService', 'CreateNetwork'}, - {'DaemonService', 'DeleteNetwork'}, - {'DaemonService', 'StartDomain'}, - {'DaemonService', 'StopDomain'}, - {'DaemonService', 'GetDomain'}, - {'DaemonService', 'ListDomains'}, - {'DaemonService', 'CreateDomain'}, - {'DaemonService', 'DeleteDomain'}, - {'DaemonService', 'DownloadImage'}, - {'DaemonService', 'GetVolume'}, - {'DaemonService', 'ListVolumes'}, - {'DaemonService', 'CreateVolume'}, - {'DaemonService', 'UpdateVolume'}, - {'DaemonService', 'DeleteVolume'}, - {'DaemonService', 'ListVolumeAttachments'}, - {'DaemonService', 'GetVolumeAttachment'}, - {'DaemonService', 'AttachVolume'}, - {'DaemonService', 'DetachVolume'}, - {'DaemonService', 'GetPortForwarding'}, - {'DaemonService', 'ListPortForwardings'}, - {'DaemonService', 'PutPortForwarding'}, - {'DaemonService', 'DeletePortForwarding'}, - {'DaemonService', 'SyncRoutes'}]; -get_rpc_containment("domain") -> - [{'DomainService', 'GetDomain'}, - {'DomainService', 'ListDomains'}, - {'DomainService', 'CreateDomain'}, - {'DomainService', 'DeleteDomain'}, - {'DomainService', 'DownloadImage'}, - {'DomainService', 'GetNetwork'}, - {'DomainService', 'ListNetworks'}, - {'DomainService', 'CreateNetwork'}, - {'DomainService', 'DeleteNetwork'}]; -get_rpc_containment("volume") -> - [{'VolumeService', 'GetVolume'}, - {'VolumeService', 'ListVolumes'}, - {'VolumeService', 'CreateVolume'}, - {'VolumeService', 'UpdateVolume'}, - {'VolumeService', 'DeleteVolume'}, - {'VolumeService', 'ListVolumeAttachments'}, - {'VolumeService', 'GetVolumeAttachment'}, - {'VolumeService', 'AttachVolume'}, - {'VolumeService', 'DetachVolume'}]; -get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; -get_rpc_containment("dns") -> [{'DNS', 'GetDNSRecord'}, {'DNS', 'ListDNSRecords'}, {'DNS', 'PutDNSRecord'}, {'DNS', 'DeleteDNSRecord'}]; -get_rpc_containment("route") -> - [{'RouteService', 'GetRouteTable'}, - {'RouteService', 'ListRouteTables'}, - {'RouteService', 'CreateRouteTable'}, - {'RouteService', 'DeleteRouteTable'}, - {'RouteService', 'GetRoute'}, - {'RouteService', 'ListRoutes'}, - {'RouteService', 'PutRoute'}, - {'RouteService', 'DeleteRoute'}, - {'RouteService', 'Sync'}]; -get_rpc_containment("timestamp") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("controller") -> []; -get_enum_containment("empty") -> []; -get_enum_containment("daemon") -> []; -get_enum_containment("domain") -> []; -get_enum_containment("volume") -> []; -get_enum_containment("port_forwarding") -> []; -get_enum_containment("dns") -> []; -get_enum_containment("route") -> []; -get_enum_containment("timestamp") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; -get_proto_by_msg_name_as_fqbin(<<"RouteTableIdentifier">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"RouteIdentifier">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"DNSRecordIdentifier">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"SyncRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"PutRouteRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRoutesRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"CreateRouteTableRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"PutDNSRecordRequest">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsRequest">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"DNSRecord">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"SyncRoutesRequest">>) -> "daemon"; -get_proto_by_msg_name_as_fqbin(<<"RouteTable">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"Route">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRoutesResponse">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesResponse">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsResponse">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"DNS">>) -> "dns"; -get_proto_by_service_name_as_fqbin(<<"RouteService">>) -> "route"; -get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; -get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; -get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; -get_proto_by_service_name_as_fqbin(<<"DaemonService">>) -> "daemon"; -get_proto_by_service_name_as_fqbin(<<"ControllerService">>) -> "controller"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/controller_service_bhvr.erl b/virtuerl/src/pb/controller_service_bhvr.erl deleted file mode 100644 index 888c9f9..0000000 --- a/virtuerl/src/pb/controller_service_bhvr.erl +++ /dev/null @@ -1,157 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service ControllerService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(controller_service_bhvr). - -%% Unary RPC --callback get_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> - {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_dns_records(ctx:t(), controller_pb:list_dns_records_request()) -> - {ok, controller_pb:list_dns_records_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_dns_record(ctx:t(), controller_pb:put_dns_record_request()) -> - {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_network(ctx:t(), controller_pb:get_network_request()) -> - {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_networks(ctx:t(), controller_pb:list_networks_request()) -> - {ok, controller_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_network(ctx:t(), controller_pb:create_network_request()) -> - {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_network(ctx:t(), controller_pb:delete_network_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback start_domain(ctx:t(), controller_pb:start_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback stop_domain(ctx:t(), controller_pb:stop_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_domain(ctx:t(), controller_pb:get_domain_request()) -> - {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_domains(ctx:t(), controller_pb:list_domains_request()) -> - {ok, controller_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_domain(ctx:t(), controller_pb:create_domain_request()) -> - {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_domain(ctx:t(), controller_pb:delete_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% --callback download_image(controller_pb:download_image_request(), grpcbox_stream:t()) -> - ok | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request()) -> - {ok, controller_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request()) -> - {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_route_table(ctx:t(), controller_pb:route_table_identifier()) -> - {ok, controller_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_route_tables(ctx:t(), controller_pb:list_route_tables_request()) -> - {ok, controller_pb:list_route_tables_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_route_table(ctx:t(), controller_pb:create_route_table_request()) -> - {ok, controller_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_route_table(ctx:t(), controller_pb:route_table_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_route(ctx:t(), controller_pb:route_identifier()) -> - {ok, controller_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_routes(ctx:t(), controller_pb:list_routes_request()) -> - {ok, controller_pb:list_routes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_route(ctx:t(), controller_pb:put_route_request()) -> - {ok, controller_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_route(ctx:t(), controller_pb:route_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback sync_routes(ctx:t(), controller_pb:sync_routes_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/controller_service_client.erl b/virtuerl/src/pb/controller_service_client.erl deleted file mode 100644 index c7ac599..0000000 --- a/virtuerl/src/pb/controller_service_client.erl +++ /dev/null @@ -1,691 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service ControllerService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(controller_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'ControllerService'). --define(PROTO_MODULE, 'controller_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_dns_record(controller_pb:dns_record_identifier()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Input) -> - get_dns_record(ctx:new(), Input, #{}). - --spec get_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - get_dns_record(Ctx, Input, #{}); -get_dns_record(Input, Options) -> - get_dns_record(ctx:new(), Input, Options). - --spec get_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetDNSRecord">>, Input, ?DEF(dns_record_identifier, dns_record, <<"DNSRecordIdentifier">>), Options). - -%% @doc Unary RPC --spec list_dns_records(controller_pb:list_dns_records_request()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Input) -> - list_dns_records(ctx:new(), Input, #{}). - --spec list_dns_records(ctx:t() | controller_pb:list_dns_records_request(), controller_pb:list_dns_records_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Ctx, Input) when ?is_ctx(Ctx) -> - list_dns_records(Ctx, Input, #{}); -list_dns_records(Input, Options) -> - list_dns_records(ctx:new(), Input, Options). - --spec list_dns_records(ctx:t(), controller_pb:list_dns_records_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListDNSRecords">>, Input, ?DEF(list_dns_records_request, list_dns_records_response, <<"ListDNSRecordsRequest">>), Options). - -%% @doc Unary RPC --spec put_dns_record(controller_pb:put_dns_record_request()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Input) -> - put_dns_record(ctx:new(), Input, #{}). - --spec put_dns_record(ctx:t() | controller_pb:put_dns_record_request(), controller_pb:put_dns_record_request() | grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - put_dns_record(Ctx, Input, #{}); -put_dns_record(Input, Options) -> - put_dns_record(ctx:new(), Input, Options). - --spec put_dns_record(ctx:t(), controller_pb:put_dns_record_request(), grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/PutDNSRecord">>, Input, ?DEF(put_dns_record_request, dns_record, <<"PutDNSRecordRequest">>), Options). - -%% @doc Unary RPC --spec delete_dns_record(controller_pb:dns_record_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Input) -> - delete_dns_record(ctx:new(), Input, #{}). - --spec delete_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - delete_dns_record(Ctx, Input, #{}); -delete_dns_record(Input, Options) -> - delete_dns_record(ctx:new(), Input, Options). - --spec delete_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteDNSRecord">>, Input, ?DEF(dns_record_identifier, empty, <<"DNSRecordIdentifier">>), Options). - -%% @doc Unary RPC --spec get_network(controller_pb:get_network_request()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Input) -> - get_network(ctx:new(), Input, #{}). - --spec get_network(ctx:t() | controller_pb:get_network_request(), controller_pb:get_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input) when ?is_ctx(Ctx) -> - get_network(Ctx, Input, #{}); -get_network(Input, Options) -> - get_network(ctx:new(), Input, Options). - --spec get_network(ctx:t(), controller_pb:get_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). - -%% @doc Unary RPC --spec list_networks(controller_pb:list_networks_request()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Input) -> - list_networks(ctx:new(), Input, #{}). - --spec list_networks(ctx:t() | controller_pb:list_networks_request(), controller_pb:list_networks_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input) when ?is_ctx(Ctx) -> - list_networks(Ctx, Input, #{}); -list_networks(Input, Options) -> - list_networks(ctx:new(), Input, Options). - --spec list_networks(ctx:t(), controller_pb:list_networks_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). - -%% @doc Unary RPC --spec create_network(controller_pb:create_network_request()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Input) -> - create_network(ctx:new(), Input, #{}). - --spec create_network(ctx:t() | controller_pb:create_network_request(), controller_pb:create_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input) when ?is_ctx(Ctx) -> - create_network(Ctx, Input, #{}); -create_network(Input, Options) -> - create_network(ctx:new(), Input, Options). - --spec create_network(ctx:t(), controller_pb:create_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). - -%% @doc Unary RPC --spec delete_network(controller_pb:delete_network_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Input) -> - delete_network(ctx:new(), Input, #{}). - --spec delete_network(ctx:t() | controller_pb:delete_network_request(), controller_pb:delete_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input) when ?is_ctx(Ctx) -> - delete_network(Ctx, Input, #{}); -delete_network(Input, Options) -> - delete_network(ctx:new(), Input, Options). - --spec delete_network(ctx:t(), controller_pb:delete_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). - -%% @doc Unary RPC --spec start_domain(controller_pb:start_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Input) -> - start_domain(ctx:new(), Input, #{}). - --spec start_domain(ctx:t() | controller_pb:start_domain_request(), controller_pb:start_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Ctx, Input) when ?is_ctx(Ctx) -> - start_domain(Ctx, Input, #{}); -start_domain(Input, Options) -> - start_domain(ctx:new(), Input, Options). - --spec start_domain(ctx:t(), controller_pb:start_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/StartDomain">>, Input, ?DEF(start_domain_request, empty, <<"StartDomainRequest">>), Options). - -%% @doc Unary RPC --spec stop_domain(controller_pb:stop_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Input) -> - stop_domain(ctx:new(), Input, #{}). - --spec stop_domain(ctx:t() | controller_pb:stop_domain_request(), controller_pb:stop_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Ctx, Input) when ?is_ctx(Ctx) -> - stop_domain(Ctx, Input, #{}); -stop_domain(Input, Options) -> - stop_domain(ctx:new(), Input, Options). - --spec stop_domain(ctx:t(), controller_pb:stop_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/StopDomain">>, Input, ?DEF(stop_domain_request, empty, <<"StopDomainRequest">>), Options). - -%% @doc Unary RPC --spec get_domain(controller_pb:get_domain_request()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Input) -> - get_domain(ctx:new(), Input, #{}). - --spec get_domain(ctx:t() | controller_pb:get_domain_request(), controller_pb:get_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input) when ?is_ctx(Ctx) -> - get_domain(Ctx, Input, #{}); -get_domain(Input, Options) -> - get_domain(ctx:new(), Input, Options). - --spec get_domain(ctx:t(), controller_pb:get_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). - -%% @doc Unary RPC --spec list_domains(controller_pb:list_domains_request()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Input) -> - list_domains(ctx:new(), Input, #{}). - --spec list_domains(ctx:t() | controller_pb:list_domains_request(), controller_pb:list_domains_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input) when ?is_ctx(Ctx) -> - list_domains(Ctx, Input, #{}); -list_domains(Input, Options) -> - list_domains(ctx:new(), Input, Options). - --spec list_domains(ctx:t(), controller_pb:list_domains_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). - -%% @doc Unary RPC --spec create_domain(controller_pb:create_domain_request()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Input) -> - create_domain(ctx:new(), Input, #{}). - --spec create_domain(ctx:t() | controller_pb:create_domain_request(), controller_pb:create_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input) when ?is_ctx(Ctx) -> - create_domain(Ctx, Input, #{}); -create_domain(Input, Options) -> - create_domain(ctx:new(), Input, Options). - --spec create_domain(ctx:t(), controller_pb:create_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). - -%% @doc Unary RPC --spec delete_domain(controller_pb:delete_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Input) -> - delete_domain(ctx:new(), Input, #{}). - --spec delete_domain(ctx:t() | controller_pb:delete_domain_request(), controller_pb:delete_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> - delete_domain(Ctx, Input, #{}); -delete_domain(Input, Options) -> - delete_domain(ctx:new(), Input, Options). - --spec delete_domain(ctx:t(), controller_pb:delete_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). - -%% @doc --spec download_image(controller_pb:download_image_request()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Input) -> - download_image(ctx:new(), Input, #{}). - --spec download_image(ctx:t() | controller_pb:download_image_request(), controller_pb:download_image_request() | grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input) when ?is_ctx(Ctx) -> - download_image(Ctx, Input, #{}); -download_image(Input, Options) -> - download_image(ctx:new(), Input, Options). - --spec download_image(ctx:t(), controller_pb:download_image_request(), grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input, Options) -> - grpcbox_client:stream(Ctx, <<"/ControllerService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). - -%% @doc Unary RPC --spec get_volume(controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Input) -> - get_volume(ctx:new(), Input, #{}). - --spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume(Ctx, Input, #{}); -get_volume(Input, Options) -> - get_volume(ctx:new(), Input, Options). - --spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volumes(controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Input) -> - list_volumes(ctx:new(), Input, #{}). - --spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> - list_volumes(Ctx, Input, #{}); -list_volumes(Input, Options) -> - list_volumes(ctx:new(), Input, Options). - --spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). - -%% @doc Unary RPC --spec create_volume(controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Input) -> - create_volume(ctx:new(), Input, #{}). - --spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input) when ?is_ctx(Ctx) -> - create_volume(Ctx, Input, #{}); -create_volume(Input, Options) -> - create_volume(ctx:new(), Input, Options). - --spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec update_volume(controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Input) -> - update_volume(ctx:new(), Input, #{}). - --spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input) when ?is_ctx(Ctx) -> - update_volume(Ctx, Input, #{}); -update_volume(Input, Options) -> - update_volume(ctx:new(), Input, Options). - --spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec delete_volume(controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Input) -> - delete_volume(ctx:new(), Input, #{}). - --spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> - delete_volume(Ctx, Input, #{}); -delete_volume(Input, Options) -> - delete_volume(ctx:new(), Input, Options). - --spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Input) -> - list_volume_attachments(ctx:new(), Input, #{}). - --spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> - list_volume_attachments(Ctx, Input, #{}); -list_volume_attachments(Input, Options) -> - list_volume_attachments(ctx:new(), Input, Options). - --spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). - -%% @doc Unary RPC --spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Input) -> - get_volume_attachment(ctx:new(), Input, #{}). - --spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume_attachment(Ctx, Input, #{}); -get_volume_attachment(Input, Options) -> - get_volume_attachment(ctx:new(), Input, Options). - --spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec attach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Input) -> - attach_volume(ctx:new(), Input, #{}). - --spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - attach_volume(Ctx, Input, #{}); -attach_volume(Input, Options) -> - attach_volume(ctx:new(), Input, Options). - --spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec detach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Input) -> - detach_volume(ctx:new(), Input, #{}). - --spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - detach_volume(Ctx, Input, #{}); -detach_volume(Input, Options) -> - detach_volume(ctx:new(), Input, Options). - --spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec get_port_forwarding(controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Input) -> - get_port_forwarding(ctx:new(), Input, #{}). - --spec get_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - get_port_forwarding(Ctx, Input, #{}); -get_port_forwarding(Input, Options) -> - get_port_forwarding(ctx:new(), Input, Options). - --spec get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). - -%% @doc Unary RPC --spec list_port_forwardings(controller_pb:list_port_forwardings_request()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Input) -> - list_port_forwardings(ctx:new(), Input, #{}). - --spec list_port_forwardings(ctx:t() | controller_pb:list_port_forwardings_request(), controller_pb:list_port_forwardings_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> - list_port_forwardings(Ctx, Input, #{}); -list_port_forwardings(Input, Options) -> - list_port_forwardings(ctx:new(), Input, Options). - --spec list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). - -%% @doc Unary RPC --spec put_port_forwarding(controller_pb:put_port_forwarding_request()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Input) -> - put_port_forwarding(ctx:new(), Input, #{}). - --spec put_port_forwarding(ctx:t() | controller_pb:put_port_forwarding_request(), controller_pb:put_port_forwarding_request() | grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - put_port_forwarding(Ctx, Input, #{}); -put_port_forwarding(Input, Options) -> - put_port_forwarding(ctx:new(), Input, Options). - --spec put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request(), grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). - -%% @doc Unary RPC --spec delete_port_forwarding(controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Input) -> - delete_port_forwarding(ctx:new(), Input, #{}). - --spec delete_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - delete_port_forwarding(Ctx, Input, #{}); -delete_port_forwarding(Input, Options) -> - delete_port_forwarding(ctx:new(), Input, Options). - --spec delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). - -%% @doc Unary RPC --spec get_route_table(controller_pb:route_table_identifier()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Input) -> - get_route_table(ctx:new(), Input, #{}). - --spec get_route_table(ctx:t() | controller_pb:route_table_identifier(), controller_pb:route_table_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - get_route_table(Ctx, Input, #{}); -get_route_table(Input, Options) -> - get_route_table(ctx:new(), Input, Options). - --spec get_route_table(ctx:t(), controller_pb:route_table_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetRouteTable">>, Input, ?DEF(route_table_identifier, route_table, <<"RouteTableIdentifier">>), Options). - -%% @doc Unary RPC --spec list_route_tables(controller_pb:list_route_tables_request()) -> - {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Input) -> - list_route_tables(ctx:new(), Input, #{}). - --spec list_route_tables(ctx:t() | controller_pb:list_route_tables_request(), controller_pb:list_route_tables_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Ctx, Input) when ?is_ctx(Ctx) -> - list_route_tables(Ctx, Input, #{}); -list_route_tables(Input, Options) -> - list_route_tables(ctx:new(), Input, Options). - --spec list_route_tables(ctx:t(), controller_pb:list_route_tables_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListRouteTables">>, Input, ?DEF(list_route_tables_request, list_route_tables_response, <<"ListRouteTablesRequest">>), Options). - -%% @doc Unary RPC --spec create_route_table(controller_pb:create_route_table_request()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Input) -> - create_route_table(ctx:new(), Input, #{}). - --spec create_route_table(ctx:t() | controller_pb:create_route_table_request(), controller_pb:create_route_table_request() | grpcbox_client:options()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - create_route_table(Ctx, Input, #{}); -create_route_table(Input, Options) -> - create_route_table(ctx:new(), Input, Options). - --spec create_route_table(ctx:t(), controller_pb:create_route_table_request(), grpcbox_client:options()) -> - {ok, controller_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/CreateRouteTable">>, Input, ?DEF(create_route_table_request, route_table, <<"CreateRouteTableRequest">>), Options). - -%% @doc Unary RPC --spec delete_route_table(controller_pb:route_table_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Input) -> - delete_route_table(ctx:new(), Input, #{}). - --spec delete_route_table(ctx:t() | controller_pb:route_table_identifier(), controller_pb:route_table_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - delete_route_table(Ctx, Input, #{}); -delete_route_table(Input, Options) -> - delete_route_table(ctx:new(), Input, Options). - --spec delete_route_table(ctx:t(), controller_pb:route_table_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteRouteTable">>, Input, ?DEF(route_table_identifier, empty, <<"RouteTableIdentifier">>), Options). - -%% @doc Unary RPC --spec get_route(controller_pb:route_identifier()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Input) -> - get_route(ctx:new(), Input, #{}). - --spec get_route(ctx:t() | controller_pb:route_identifier(), controller_pb:route_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Ctx, Input) when ?is_ctx(Ctx) -> - get_route(Ctx, Input, #{}); -get_route(Input, Options) -> - get_route(ctx:new(), Input, Options). - --spec get_route(ctx:t(), controller_pb:route_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/GetRoute">>, Input, ?DEF(route_identifier, route, <<"RouteIdentifier">>), Options). - -%% @doc Unary RPC --spec list_routes(controller_pb:list_routes_request()) -> - {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Input) -> - list_routes(ctx:new(), Input, #{}). - --spec list_routes(ctx:t() | controller_pb:list_routes_request(), controller_pb:list_routes_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Ctx, Input) when ?is_ctx(Ctx) -> - list_routes(Ctx, Input, #{}); -list_routes(Input, Options) -> - list_routes(ctx:new(), Input, Options). - --spec list_routes(ctx:t(), controller_pb:list_routes_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/ListRoutes">>, Input, ?DEF(list_routes_request, list_routes_response, <<"ListRoutesRequest">>), Options). - -%% @doc Unary RPC --spec put_route(controller_pb:put_route_request()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Input) -> - put_route(ctx:new(), Input, #{}). - --spec put_route(ctx:t() | controller_pb:put_route_request(), controller_pb:put_route_request() | grpcbox_client:options()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Ctx, Input) when ?is_ctx(Ctx) -> - put_route(Ctx, Input, #{}); -put_route(Input, Options) -> - put_route(ctx:new(), Input, Options). - --spec put_route(ctx:t(), controller_pb:put_route_request(), grpcbox_client:options()) -> - {ok, controller_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/PutRoute">>, Input, ?DEF(put_route_request, route, <<"PutRouteRequest">>), Options). - -%% @doc Unary RPC --spec delete_route(controller_pb:route_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Input) -> - delete_route(ctx:new(), Input, #{}). - --spec delete_route(ctx:t() | controller_pb:route_identifier(), controller_pb:route_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Ctx, Input) when ?is_ctx(Ctx) -> - delete_route(Ctx, Input, #{}); -delete_route(Input, Options) -> - delete_route(ctx:new(), Input, Options). - --spec delete_route(ctx:t(), controller_pb:route_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/DeleteRoute">>, Input, ?DEF(route_identifier, empty, <<"RouteIdentifier">>), Options). - -%% @doc Unary RPC --spec sync_routes(controller_pb:sync_routes_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Input) -> - sync_routes(ctx:new(), Input, #{}). - --spec sync_routes(ctx:t() | controller_pb:sync_routes_request(), controller_pb:sync_routes_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Ctx, Input) when ?is_ctx(Ctx) -> - sync_routes(Ctx, Input, #{}); -sync_routes(Input, Options) -> - sync_routes(ctx:new(), Input, Options). - --spec sync_routes(ctx:t(), controller_pb:sync_routes_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/ControllerService/SyncRoutes">>, Input, ?DEF(sync_routes_request, empty, <<"SyncRoutesRequest">>), Options). - diff --git a/virtuerl/src/pb/daemon_pb.erl b/virtuerl/src/pb/daemon_pb.erl deleted file mode 100644 index 47d53fc..0000000 --- a/virtuerl/src/pb/daemon_pb.erl +++ /dev/null @@ -1,5962 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(daemon_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type sync_routes_request() :: - #{ - }. - --type empty() :: - #{ - }. - --type start_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata() % = 2, optional - }. - --type stop_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata(), % = 2, optional - force => boolean() | 0 | 1 % = 3, optional - }. - --type get_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type domain() :: - #{id => non_neg_integer(), % = 1, optional, 64 bits - uuid => unicode:chardata(), % = 2, optional - name => unicode:chardata(), % = 3, optional - vcpu => non_neg_integer(), % = 4, optional, 32 bits - memory => non_neg_integer(), % = 5, optional, 64 bits - network => unicode:chardata(), % = 6, optional - bridge => unicode:chardata(), % = 7, optional - state => unicode:chardata(), % = 8, optional - private_ip => unicode:chardata(), % = 9, optional - ipv6_address => unicode:chardata(), % = 15, optional - user_data => unicode:chardata(), % = 10, optional - nested_virtualization => boolean() | 0 | 1, % = 11, optional - base_image => unicode:chardata(), % = 12, optional - created_at => timestamp(), % = 13, optional - os_type => unicode:chardata() % = 14, optional - }. - --type list_domains_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_domains_response() :: - #{domains => [domain()] % = 1, repeated - }. - --type create_domain_request() :: - #{domain => domain(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type download_image_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type image_chunk() :: - #{bytes => iodata() % = 1, optional - }. - --type get_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type network() :: - #{uuid => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - cidr => unicode:chardata(), % = 3, optional - cidr6 => unicode:chardata() % = 4, optional - }. - --type list_networks_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_networks_response() :: - #{networks => [network()] % = 1, repeated - }. - --type create_network_request() :: - #{network => network(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type get_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume() :: - #{id => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - size => non_neg_integer() % = 3, optional, 64 bits - }. - --type list_volumes_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_volumes_response() :: - #{volumes => [volume()] % = 1, repeated - }. - --type create_volume_request() :: - #{volume => volume(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type update_volume_request() :: - #{host => unicode:chardata(), % = 1, optional - volume => volume() % = 2, optional - }. - --type delete_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume_attachment_identifier() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - host => unicode:chardata() % = 3, optional - }. - --type volume_attachment() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - disk_address => unicode:chardata() % = 3, optional - }. - --type list_volume_attachments_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type list_volume_attachments_response() :: - #{attachments => [volume_attachment()] % = 1, repeated - }. - --type port_forwarding_identifier() :: - #{host => unicode:chardata(), % = 1, optional - protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer() % = 3, optional, 32 bits - }. - --type port_forwarding() :: - #{protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer(), % = 3, optional, 32 bits - target_ip => unicode:chardata(), % = 4, optional - target_port => non_neg_integer() % = 5, optional, 32 bits - }. - --type list_port_forwardings_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_port_forwardings_response() :: - #{port_forwardings => [port_forwarding()] % = 1, repeated - }. - --type put_port_forwarding_request() :: - #{port_forwarding => port_forwarding(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type timestamp() :: - #{seconds => integer(), % = 1, optional, 64 bits - nanos => integer() % = 2, optional, 32 bits - }. - --export_type(['sync_routes_request'/0, 'empty'/0, 'start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'timestamp'/0]). --type '$msg_name'() :: sync_routes_request | empty | start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | timestamp. --type '$msg'() :: sync_routes_request() | empty() | start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | timestamp(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - sync_routes_request -> encode_msg_sync_routes_request(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); - start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); - stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); - get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); - domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); - list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); - list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); - create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); - delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); - download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); - image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); - get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); - network -> encode_msg_network(id(Msg, TrUserData), TrUserData); - list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); - list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); - create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); - delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); - get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); - volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); - list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); - list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); - create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); - update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); - delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); - volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); - volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); - list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); - list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); - port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); - port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); - list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); - list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); - put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); - timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_sync_routes_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{force := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= false -> B2; - true -> e_type_bool(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). - - -encode_msg_domain(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{name := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{vcpu := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{memory := F5} -> - begin - TrF5 = id(F5, TrUserData), - if TrF5 =:= 0 -> B4; - true -> e_varint(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{network := F6} -> - begin - TrF6 = id(F6, TrUserData), - case is_empty_string(TrF6) of - true -> B5; - false -> e_type_string(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - B7 = case M of - #{bridge := F7} -> - begin - TrF7 = id(F7, TrUserData), - case is_empty_string(TrF7) of - true -> B6; - false -> e_type_string(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end, - B8 = case M of - #{state := F8} -> - begin - TrF8 = id(F8, TrUserData), - case is_empty_string(TrF8) of - true -> B7; - false -> e_type_string(TrF8, <>, TrUserData) - end - end; - _ -> B7 - end, - B9 = case M of - #{private_ip := F9} -> - begin - TrF9 = id(F9, TrUserData), - case is_empty_string(TrF9) of - true -> B8; - false -> e_type_string(TrF9, <>, TrUserData) - end - end; - _ -> B8 - end, - B10 = case M of - #{ipv6_address := F10} -> - begin - TrF10 = id(F10, TrUserData), - case is_empty_string(TrF10) of - true -> B9; - false -> e_type_string(TrF10, <>, TrUserData) - end - end; - _ -> B9 - end, - B11 = case M of - #{user_data := F11} -> - begin - TrF11 = id(F11, TrUserData), - case is_empty_string(TrF11) of - true -> B10; - false -> e_type_string(TrF11, <>, TrUserData) - end - end; - _ -> B10 - end, - B12 = case M of - #{nested_virtualization := F12} -> - begin - TrF12 = id(F12, TrUserData), - if TrF12 =:= false -> B11; - true -> e_type_bool(TrF12, <>, TrUserData) - end - end; - _ -> B11 - end, - B13 = case M of - #{base_image := F13} -> - begin - TrF13 = id(F13, TrUserData), - case is_empty_string(TrF13) of - true -> B12; - false -> e_type_string(TrF13, <>, TrUserData) - end - end; - _ -> B12 - end, - B14 = case M of - #{created_at := F14} -> - begin - TrF14 = id(F14, TrUserData), - if TrF14 =:= undefined -> B13; - true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) - end - end; - _ -> B13 - end, - case M of - #{os_type := F15} -> - begin - TrF15 = id(F15, TrUserData), - case is_empty_string(TrF15) of - true -> B14; - false -> e_type_string(TrF15, <>, TrUserData) - end - end; - _ -> B14 - end. - -encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> - case M of - #{domains := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). - - -encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). - - -encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> - case M of - #{bytes := F1} -> - begin - TrF1 = id(F1, TrUserData), - case iolist_size(TrF1) of - 0 -> Bin; - _ -> e_type_bytes(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). - - -encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). - - -encode_msg_network(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{cidr := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{cidr6 := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> - case M of - #{networks := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). - - -encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{network := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). - - -encode_msg_volume(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{size := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> - case M of - #{volumes := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{volume := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{volume := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= undefined -> B1; - true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{host := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{disk_address := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> - case M of - #{attachments := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{protocol := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{source_port := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{protocol := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{source_port := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{target_ip := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{target_port := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> - case M of - #{port_forwardings := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). - - -encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{port_forwarding := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). - - -encode_msg_timestamp(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{seconds := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_type_int64(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{nanos := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_type_int32(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -e_mfield_domain_created_at(Msg, Bin, TrUserData) -> - SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_domains_response_domains(Rest, Bin3, TrUserData); -e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. - -e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_networks_response_networks(Rest, Bin3, TrUserData); -e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. - -e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); -e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. - -e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); -e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. - -e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); -e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. - -e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(sync_routes_request, Bin, TrUserData) -> id(decode_msg_sync_routes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); -decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). - - - -decode_msg_sync_routes_request(Bin, TrUserData) -> dfp_read_field_def_sync_routes_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_routes_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_sync_routes_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_sync_routes_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_sync_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_routes_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_sync_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_sync_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_routes_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_sync_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_sync_routes_request(Rest2, 0, 0, F, TrUserData). - -skip_group_sync_routes_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_sync_routes_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_sync_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_sync_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_routes_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; -dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. - -d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). - -dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; -dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. - -d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_domain(Bin, TrUserData) -> - dfp_read_field_def_domain(Bin, - 0, - 0, - 0, - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(false, TrUserData), - id(<<>>, TrUserData), - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end; -dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> - dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) - end - end; -dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end. - -d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). - -d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, - 0, - 0, - F, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - F@_13, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) - end, - F@_15, - TrUserData). - -d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). - -skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end. - -d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end; -dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end. - -d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_domain(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; -dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. - -d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; -dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. - -d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end. - -d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end; -dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end. - -d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_network(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; -dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. - -d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end; -dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end. - -d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end; -dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end. - -d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, - 0, - 0, - F, - F@_1, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; -dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. - -d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; -dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. - -d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; -dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. - -d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; -dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. - -d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end. - -d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end; -dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end. - -d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; -dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. - -d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - sync_routes_request -> merge_msg_sync_routes_request(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData); - start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); - stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); - get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); - domain -> merge_msg_domain(Prev, New, TrUserData); - list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); - list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); - create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); - delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); - download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); - image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); - get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); - network -> merge_msg_network(Prev, New, TrUserData); - list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); - list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); - create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); - delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); - get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); - volume -> merge_msg_volume(Prev, New, TrUserData); - list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); - list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); - create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); - update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); - delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); - volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); - volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); - list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); - list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); - port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); - port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); - list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); - list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); - put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); - timestamp -> merge_msg_timestamp(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_sync_routes_request/3}). -merge_msg_sync_routes_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_start_domain_request/3}). -merge_msg_start_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). -merge_msg_stop_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{force := NFforce}} -> S3#{force => NFforce}; - {#{force := PFforce}, _} -> S3#{force => PFforce}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_get_domain_request/3}). -merge_msg_get_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_domain/3}). -merge_msg_domain(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S3#{name => NFname}; - {#{name := PFname}, _} -> S3#{name => PFname}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; - {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; - {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; - _ -> S6 - end, - S8 = case {PMsg, NMsg} of - {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; - {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; - _ -> S7 - end, - S9 = case {PMsg, NMsg} of - {_, #{state := NFstate}} -> S8#{state => NFstate}; - {#{state := PFstate}, _} -> S8#{state => PFstate}; - _ -> S8 - end, - S10 = case {PMsg, NMsg} of - {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; - {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; - _ -> S9 - end, - S11 = case {PMsg, NMsg} of - {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; - {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; - _ -> S10 - end, - S12 = case {PMsg, NMsg} of - {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; - {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; - _ -> S11 - end, - S13 = case {PMsg, NMsg} of - {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; - {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; - _ -> S12 - end, - S14 = case {PMsg, NMsg} of - {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; - {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; - _ -> S13 - end, - S15 = case {PMsg, NMsg} of - {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; - {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; - {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; - {_, _} -> S14 - end, - case {PMsg, NMsg} of - {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; - {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; - _ -> S15 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_request/3}). -merge_msg_list_domains_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_response/3}). -merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; - {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; - {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_domain_request/3}). -merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; - {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; - {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). -merge_msg_delete_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_download_image_request/3}). -merge_msg_download_image_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_image_chunk/3}). -merge_msg_image_chunk(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; - {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_get_network_request/3}). -merge_msg_get_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_network/3}). -merge_msg_network(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; - {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; - {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_request/3}). -merge_msg_list_networks_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_response/3}). -merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; - {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; - {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_network_request/3}). -merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; - {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_network_request/3}). -merge_msg_delete_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_get_volume_request/3}). -merge_msg_get_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume/3}). -merge_msg_volume(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{size := NFsize}} -> S3#{size => NFsize}; - {#{size := PFsize}, _} -> S3#{size => PFsize}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). -merge_msg_list_volumes_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). -merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; - {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; - {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_volume_request/3}). -merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_update_volume_request/3}). -merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). -merge_msg_delete_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). -merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S3#{host => NFhost}; - {#{host := PFhost}, _} -> S3#{host => PFhost}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment/3}). -merge_msg_volume_attachment(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; - {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). -merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). -merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; - {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; - {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). -merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding/3}). -merge_msg_port_forwarding(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; - {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; - {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). -merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). -merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; - {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; - {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). -merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; - {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; - {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_timestamp/3}). -merge_msg_timestamp(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; - {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; - {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; - _ -> S2 - end. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - sync_routes_request -> v_msg_sync_routes_request(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); - stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); - get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); - domain -> v_msg_domain(Msg, [MsgName], TrUserData); - list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); - list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); - create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); - delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); - download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); - image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); - get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); - network -> v_msg_network(Msg, [MsgName], TrUserData); - list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); - list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); - create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); - delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); - get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); - volume -> v_msg_volume(Msg, [MsgName], TrUserData); - list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); - list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); - create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); - update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); - delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); - volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); - volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); - list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); - list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); - port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); - port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); - list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); - list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); - put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); - timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_sync_routes_request/3}). --dialyzer({nowarn_function,v_msg_sync_routes_request/3}). -v_msg_sync_routes_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_sync_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_routes_request}, M, Path); -v_msg_sync_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_routes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_msg_start_domain_request/3}). --dialyzer({nowarn_function,v_msg_start_domain_request/3}). -v_msg_start_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); -v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_stop_domain_request/3}). --dialyzer({nowarn_function,v_msg_stop_domain_request/3}). -v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (force) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); -v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_get_domain_request/3}). --dialyzer({nowarn_function,v_msg_get_domain_request/3}). -v_msg_get_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); -v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_domain/3}). --dialyzer({nowarn_function,v_msg_domain/3}). -v_msg_domain(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); - _ -> ok - end, - case M of - #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); - _ -> ok - end, - case M of - #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); - _ -> ok - end, - case M of - #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); - _ -> ok - end, - case M of - #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); - _ -> ok - end, - case M of - #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); - _ -> ok - end, - case M of - #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); - _ -> ok - end, - case M of - #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); - _ -> ok - end, - case M of - #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); - _ -> ok - end, - case M of - #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (uuid) -> ok; - (name) -> ok; - (vcpu) -> ok; - (memory) -> ok; - (network) -> ok; - (bridge) -> ok; - (state) -> ok; - (private_ip) -> ok; - (ipv6_address) -> ok; - (user_data) -> ok; - (nested_virtualization) -> ok; - (base_image) -> ok; - (created_at) -> ok; - (os_type) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); -v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_request/3}). --dialyzer({nowarn_function,v_msg_list_domains_request/3}). -v_msg_list_domains_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); -v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_response/3}). --dialyzer({nowarn_function,v_msg_list_domains_response/3}). -v_msg_list_domains_response(#{} = M, Path, TrUserData) -> - case M of - #{domains := F1} -> - if is_list(F1) -> - _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) - end; - _ -> ok - end, - lists:foreach(fun (domains) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); -v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_domain_request/3}). --dialyzer({nowarn_function,v_msg_create_domain_request/3}). -v_msg_create_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); -v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_domain_request/3}). --dialyzer({nowarn_function,v_msg_delete_domain_request/3}). -v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); -v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_download_image_request/3}). --dialyzer({nowarn_function,v_msg_download_image_request/3}). -v_msg_download_image_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); -v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). - --compile({nowarn_unused_function,v_msg_image_chunk/3}). --dialyzer({nowarn_function,v_msg_image_chunk/3}). -v_msg_image_chunk(#{} = M, Path, TrUserData) -> - case M of - #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (bytes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); -v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). - --compile({nowarn_unused_function,v_msg_get_network_request/3}). --dialyzer({nowarn_function,v_msg_get_network_request/3}). -v_msg_get_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); -v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_network/3}). --dialyzer({nowarn_function,v_msg_network/3}). -v_msg_network(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (name) -> ok; - (cidr) -> ok; - (cidr6) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); -v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_request/3}). --dialyzer({nowarn_function,v_msg_list_networks_request/3}). -v_msg_list_networks_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); -v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_response/3}). --dialyzer({nowarn_function,v_msg_list_networks_response/3}). -v_msg_list_networks_response(#{} = M, Path, TrUserData) -> - case M of - #{networks := F1} -> - if is_list(F1) -> - _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) - end; - _ -> ok - end, - lists:foreach(fun (networks) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); -v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_network_request/3}). --dialyzer({nowarn_function,v_msg_create_network_request/3}). -v_msg_create_network_request(#{} = M, Path, TrUserData) -> - case M of - #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); -v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_network_request/3}). --dialyzer({nowarn_function,v_msg_delete_network_request/3}). -v_msg_delete_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); -v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_get_volume_request/3}). --dialyzer({nowarn_function,v_msg_get_volume_request/3}). -v_msg_get_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); -v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume/3}). --dialyzer({nowarn_function,v_msg_volume/3}). -v_msg_volume(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (name) -> ok; - (size) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); -v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_request/3}). --dialyzer({nowarn_function,v_msg_list_volumes_request/3}). -v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); -v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_response/3}). --dialyzer({nowarn_function,v_msg_list_volumes_response/3}). -v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> - case M of - #{volumes := F1} -> - if is_list(F1) -> - _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) - end; - _ -> ok - end, - lists:foreach(fun (volumes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); -v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_volume_request/3}). --dialyzer({nowarn_function,v_msg_create_volume_request/3}). -v_msg_create_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (volume) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); -v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_update_volume_request/3}). --dialyzer({nowarn_function,v_msg_update_volume_request/3}). -v_msg_update_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (volume) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); -v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_volume_request/3}). --dialyzer({nowarn_function,v_msg_delete_volume_request/3}). -v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); -v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). --dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). -v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); -v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment/3}). --dialyzer({nowarn_function,v_msg_volume_attachment/3}). -v_msg_volume_attachment(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (disk_address) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); -v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). -v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); -v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). -v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> - case M of - #{attachments := F1} -> - if is_list(F1) -> - _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) - end; - _ -> ok - end, - lists:foreach(fun (attachments) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); -v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). - --compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). --dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). -v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (protocol) -> ok; - (source_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); -v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_port_forwarding/3}). --dialyzer({nowarn_function,v_msg_port_forwarding/3}). -v_msg_port_forwarding(#{} = M, Path, TrUserData) -> - case M of - #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); - _ -> ok - end, - case M of - #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (protocol) -> ok; - (source_port) -> ok; - (target_ip) -> ok; - (target_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); -v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). -v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); -v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). -v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> - case M of - #{port_forwardings := F1} -> - if is_list(F1) -> - _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) - end; - _ -> ok - end, - lists:foreach(fun (port_forwardings) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); -v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). --dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). -v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> - case M of - #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (port_forwarding) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); -v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). - --compile({nowarn_unused_function,v_msg_timestamp/3}). --dialyzer({nowarn_function,v_msg_timestamp/3}). -v_msg_timestamp(#{} = M, Path, TrUserData) -> - case M of - #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); - _ -> ok - end, - case M of - #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (seconds) -> ok; - (nanos) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); -v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). - --compile({nowarn_unused_function,v_type_int32/3}). --dialyzer({nowarn_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; -v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); -v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). - --compile({nowarn_unused_function,v_type_int64/3}). --dialyzer({nowarn_function,v_type_int64/3}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; -v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); -v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; -v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); -v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; -v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); -v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). - --compile({nowarn_unused_function,v_type_bool/3}). --dialyzer({nowarn_function,v_type_bool/3}). -v_type_bool(false, _Path, _TrUserData) -> ok; -v_type_bool(true, _Path, _TrUserData) -> ok; -v_type_bool(0, _Path, _TrUserData) -> ok; -v_type_bool(1, _Path, _TrUserData) -> ok; -v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,v_type_bytes/3}). --dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; -v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, sync_routes_request}, []}, - {{msg, empty}, []}, - {{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, stop_domain_request}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, - {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, domain}, - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, - {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, - {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, network}, - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, - {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume}, - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, - {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, - {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, - {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment_identifier}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, - {{msg, port_forwarding_identifier}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, - {{msg, port_forwarding}, - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, - {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. - - -get_msg_names() -> - [sync_routes_request, - empty, - start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - port_forwarding_identifier, - port_forwarding, - list_port_forwardings_request, - list_port_forwardings_response, - put_port_forwarding_request, - timestamp]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [sync_routes_request, - empty, - start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - port_forwarding_identifier, - port_forwarding, - list_port_forwardings_request, - list_port_forwardings_response, - put_port_forwarding_request, - timestamp]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(sync_routes_request) -> []; -find_msg_def(empty) -> []; -find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(stop_domain_request) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; -find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(domain) -> - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; -find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; -find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(network) -> - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; -find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume) -> - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; -find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; -find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment_identifier) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; -find_msg_def(port_forwarding_identifier) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(port_forwarding) -> - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; -find_msg_def(put_port_forwarding_request) -> - [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['DaemonService', 'DomainService', 'VolumeService', 'PortForwardingService']. - - -get_service_def('DaemonService') -> - {{service, 'DaemonService'}, - [#{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('DomainService') -> - {{service, 'DomainService'}, - [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('VolumeService') -> - {{service, 'VolumeService'}, - [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def('PortForwardingService') -> - {{service, 'PortForwardingService'}, - [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('DaemonService') -> - ['GetNetwork', - 'ListNetworks', - 'CreateNetwork', - 'DeleteNetwork', - 'StartDomain', - 'StopDomain', - 'GetDomain', - 'ListDomains', - 'CreateDomain', - 'DeleteDomain', - 'DownloadImage', - 'GetVolume', - 'ListVolumes', - 'CreateVolume', - 'UpdateVolume', - 'DeleteVolume', - 'ListVolumeAttachments', - 'GetVolumeAttachment', - 'AttachVolume', - 'DetachVolume', - 'GetPortForwarding', - 'ListPortForwardings', - 'PutPortForwarding', - 'DeletePortForwarding', - 'SyncRoutes']; -get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; -get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; -get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; -get_rpc_names(_) -> error. - - -find_rpc_def('DaemonService', RpcName) -> find_rpc_def_DaemonService(RpcName); -find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); -find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); -find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_DaemonService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('StartDomain') -> #{name => 'StartDomain', input => start_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('StopDomain') -> #{name => 'StopDomain', input => stop_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_DaemonService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService('SyncRoutes') -> #{name => 'SyncRoutes', input => sync_routes_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DaemonService(_) -> error. - -find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService(_) -> error. - -find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService(_) -> error. - -find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"DaemonService">>) -> 'DaemonService'; -fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; -fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; -fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('DaemonService') -> <<"DaemonService">>; -service_name_to_fqbin('DomainService') -> <<"DomainService">>; -service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; -service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetNetwork">>) -> {'DaemonService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListNetworks">>) -> {'DaemonService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateNetwork">>) -> {'DaemonService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteNetwork">>) -> {'DaemonService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StartDomain">>) -> {'DaemonService', 'StartDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"StopDomain">>) -> {'DaemonService', 'StopDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetDomain">>) -> {'DaemonService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListDomains">>) -> {'DaemonService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateDomain">>) -> {'DaemonService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteDomain">>) -> {'DaemonService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DownloadImage">>) -> {'DaemonService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolume">>) -> {'DaemonService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumes">>) -> {'DaemonService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"CreateVolume">>) -> {'DaemonService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"UpdateVolume">>) -> {'DaemonService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeleteVolume">>) -> {'DaemonService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListVolumeAttachments">>) -> {'DaemonService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetVolumeAttachment">>) -> {'DaemonService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"AttachVolume">>) -> {'DaemonService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DetachVolume">>) -> {'DaemonService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"GetPortForwarding">>) -> {'DaemonService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"ListPortForwardings">>) -> {'DaemonService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"PutPortForwarding">>) -> {'DaemonService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"DeletePortForwarding">>) -> {'DaemonService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(<<"DaemonService">>, <<"SyncRoutes">>) -> {'DaemonService', 'SyncRoutes'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('DaemonService', 'GetNetwork') -> {<<"DaemonService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListNetworks') -> {<<"DaemonService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateNetwork') -> {<<"DaemonService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteNetwork') -> {<<"DaemonService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'StartDomain') -> {<<"DaemonService">>, <<"StartDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'StopDomain') -> {<<"DaemonService">>, <<"StopDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetDomain') -> {<<"DaemonService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListDomains') -> {<<"DaemonService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateDomain') -> {<<"DaemonService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteDomain') -> {<<"DaemonService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DownloadImage') -> {<<"DaemonService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetVolume') -> {<<"DaemonService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumes') -> {<<"DaemonService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'CreateVolume') -> {<<"DaemonService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'UpdateVolume') -> {<<"DaemonService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeleteVolume') -> {<<"DaemonService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListVolumeAttachments') -> {<<"DaemonService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetVolumeAttachment') -> {<<"DaemonService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'AttachVolume') -> {<<"DaemonService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DetachVolume') -> {<<"DaemonService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'GetPortForwarding') -> {<<"DaemonService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'ListPortForwardings') -> {<<"DaemonService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'PutPortForwarding') -> {<<"DaemonService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'DeletePortForwarding') -> {<<"DaemonService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins('DaemonService', 'SyncRoutes') -> {<<"DaemonService">>, <<"SyncRoutes">>}; -service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"SyncRoutesRequest">>) -> sync_routes_request; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; -fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; -fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; -fqbin_to_msg_name(<<"Domain">>) -> domain; -fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; -fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; -fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; -fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; -fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; -fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; -fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; -fqbin_to_msg_name(<<"Network">>) -> network; -fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; -fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; -fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; -fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; -fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; -fqbin_to_msg_name(<<"Volume">>) -> volume; -fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; -fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; -fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; -fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; -fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; -fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; -fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; -fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; -fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; -fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; -fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; -fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; -fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; -fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; -fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(sync_routes_request) -> <<"SyncRoutesRequest">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; -msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; -msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; -msg_name_to_fqbin(domain) -> <<"Domain">>; -msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; -msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; -msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; -msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; -msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; -msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; -msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; -msg_name_to_fqbin(network) -> <<"Network">>; -msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; -msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; -msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; -msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; -msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; -msg_name_to_fqbin(volume) -> <<"Volume">>; -msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; -msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; -msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; -msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; -msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; -msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; -msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; -msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; -msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; -msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; -msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; -msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; -msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; -msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; -msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "daemon.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["daemon.proto", "empty.proto", "domain.proto", "volume.proto", "port_forwarding.proto", "timestamp.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["daemon", "empty", "domain", "volume", "port_forwarding", "timestamp"]. - - -get_msg_containment("daemon") -> [sync_routes_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment("domain") -> - [create_domain_request, - create_network_request, - delete_domain_request, - delete_network_request, - domain, - download_image_request, - get_domain_request, - get_network_request, - image_chunk, - list_domains_request, - list_domains_response, - list_networks_request, - list_networks_response, - network, - start_domain_request, - stop_domain_request]; -get_msg_containment("volume") -> - [create_volume_request, - delete_volume_request, - get_volume_request, - list_volume_attachments_request, - list_volume_attachments_response, - list_volumes_request, - list_volumes_response, - update_volume_request, - volume, - volume_attachment, - volume_attachment_identifier]; -get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; -get_msg_containment("timestamp") -> [timestamp]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("daemon") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment("domain") -> undefined; -get_pkg_containment("volume") -> undefined; -get_pkg_containment("port_forwarding") -> undefined; -get_pkg_containment("timestamp") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("daemon") -> ['DaemonService']; -get_service_containment("empty") -> []; -get_service_containment("domain") -> ['DomainService']; -get_service_containment("volume") -> ['VolumeService']; -get_service_containment("port_forwarding") -> ['PortForwardingService']; -get_service_containment("timestamp") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("daemon") -> - [{'DaemonService', 'GetNetwork'}, - {'DaemonService', 'ListNetworks'}, - {'DaemonService', 'CreateNetwork'}, - {'DaemonService', 'DeleteNetwork'}, - {'DaemonService', 'StartDomain'}, - {'DaemonService', 'StopDomain'}, - {'DaemonService', 'GetDomain'}, - {'DaemonService', 'ListDomains'}, - {'DaemonService', 'CreateDomain'}, - {'DaemonService', 'DeleteDomain'}, - {'DaemonService', 'DownloadImage'}, - {'DaemonService', 'GetVolume'}, - {'DaemonService', 'ListVolumes'}, - {'DaemonService', 'CreateVolume'}, - {'DaemonService', 'UpdateVolume'}, - {'DaemonService', 'DeleteVolume'}, - {'DaemonService', 'ListVolumeAttachments'}, - {'DaemonService', 'GetVolumeAttachment'}, - {'DaemonService', 'AttachVolume'}, - {'DaemonService', 'DetachVolume'}, - {'DaemonService', 'GetPortForwarding'}, - {'DaemonService', 'ListPortForwardings'}, - {'DaemonService', 'PutPortForwarding'}, - {'DaemonService', 'DeletePortForwarding'}, - {'DaemonService', 'SyncRoutes'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment("domain") -> - [{'DomainService', 'GetDomain'}, - {'DomainService', 'ListDomains'}, - {'DomainService', 'CreateDomain'}, - {'DomainService', 'DeleteDomain'}, - {'DomainService', 'DownloadImage'}, - {'DomainService', 'GetNetwork'}, - {'DomainService', 'ListNetworks'}, - {'DomainService', 'CreateNetwork'}, - {'DomainService', 'DeleteNetwork'}]; -get_rpc_containment("volume") -> - [{'VolumeService', 'GetVolume'}, - {'VolumeService', 'ListVolumes'}, - {'VolumeService', 'CreateVolume'}, - {'VolumeService', 'UpdateVolume'}, - {'VolumeService', 'DeleteVolume'}, - {'VolumeService', 'ListVolumeAttachments'}, - {'VolumeService', 'GetVolumeAttachment'}, - {'VolumeService', 'AttachVolume'}, - {'VolumeService', 'DetachVolume'}]; -get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; -get_rpc_containment("timestamp") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("daemon") -> []; -get_enum_containment("empty") -> []; -get_enum_containment("domain") -> []; -get_enum_containment("volume") -> []; -get_enum_containment("port_forwarding") -> []; -get_enum_containment("timestamp") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; -get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"SyncRoutesRequest">>) -> "daemon"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; -get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; -get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; -get_proto_by_service_name_as_fqbin(<<"DaemonService">>) -> "daemon"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/daemon_service_bhvr.erl b/virtuerl/src/pb/daemon_service_bhvr.erl deleted file mode 100644 index a722be8..0000000 --- a/virtuerl/src/pb/daemon_service_bhvr.erl +++ /dev/null @@ -1,109 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service DaemonService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(daemon_service_bhvr). - -%% Unary RPC --callback get_network(ctx:t(), controller_pb:get_network_request()) -> - {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_networks(ctx:t(), controller_pb:list_networks_request()) -> - {ok, controller_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_network(ctx:t(), controller_pb:create_network_request()) -> - {ok, controller_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_network(ctx:t(), controller_pb:delete_network_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback start_domain(ctx:t(), controller_pb:start_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback stop_domain(ctx:t(), controller_pb:stop_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_domain(ctx:t(), controller_pb:get_domain_request()) -> - {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_domains(ctx:t(), controller_pb:list_domains_request()) -> - {ok, controller_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_domain(ctx:t(), controller_pb:create_domain_request()) -> - {ok, controller_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_domain(ctx:t(), controller_pb:delete_domain_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% --callback download_image(controller_pb:download_image_request(), grpcbox_stream:t()) -> - ok | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request()) -> - {ok, controller_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request()) -> - {ok, controller_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback sync_routes(ctx:t(), controller_pb:sync_routes_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/daemon_service_client.erl b/virtuerl/src/pb/daemon_service_client.erl deleted file mode 100644 index d02ee59..0000000 --- a/virtuerl/src/pb/daemon_service_client.erl +++ /dev/null @@ -1,475 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service DaemonService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(daemon_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'DaemonService'). --define(PROTO_MODULE, 'controller_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_network(controller_pb:get_network_request()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Input) -> - get_network(ctx:new(), Input, #{}). - --spec get_network(ctx:t() | controller_pb:get_network_request(), controller_pb:get_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input) when ?is_ctx(Ctx) -> - get_network(Ctx, Input, #{}); -get_network(Input, Options) -> - get_network(ctx:new(), Input, Options). - --spec get_network(ctx:t(), controller_pb:get_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). - -%% @doc Unary RPC --spec list_networks(controller_pb:list_networks_request()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Input) -> - list_networks(ctx:new(), Input, #{}). - --spec list_networks(ctx:t() | controller_pb:list_networks_request(), controller_pb:list_networks_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input) when ?is_ctx(Ctx) -> - list_networks(Ctx, Input, #{}); -list_networks(Input, Options) -> - list_networks(ctx:new(), Input, Options). - --spec list_networks(ctx:t(), controller_pb:list_networks_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). - -%% @doc Unary RPC --spec create_network(controller_pb:create_network_request()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Input) -> - create_network(ctx:new(), Input, #{}). - --spec create_network(ctx:t() | controller_pb:create_network_request(), controller_pb:create_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input) when ?is_ctx(Ctx) -> - create_network(Ctx, Input, #{}); -create_network(Input, Options) -> - create_network(ctx:new(), Input, Options). - --spec create_network(ctx:t(), controller_pb:create_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). - -%% @doc Unary RPC --spec delete_network(controller_pb:delete_network_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Input) -> - delete_network(ctx:new(), Input, #{}). - --spec delete_network(ctx:t() | controller_pb:delete_network_request(), controller_pb:delete_network_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input) when ?is_ctx(Ctx) -> - delete_network(Ctx, Input, #{}); -delete_network(Input, Options) -> - delete_network(ctx:new(), Input, Options). - --spec delete_network(ctx:t(), controller_pb:delete_network_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). - -%% @doc Unary RPC --spec start_domain(controller_pb:start_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Input) -> - start_domain(ctx:new(), Input, #{}). - --spec start_domain(ctx:t() | controller_pb:start_domain_request(), controller_pb:start_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Ctx, Input) when ?is_ctx(Ctx) -> - start_domain(Ctx, Input, #{}); -start_domain(Input, Options) -> - start_domain(ctx:new(), Input, Options). - --spec start_domain(ctx:t(), controller_pb:start_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -start_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/StartDomain">>, Input, ?DEF(start_domain_request, empty, <<"StartDomainRequest">>), Options). - -%% @doc Unary RPC --spec stop_domain(controller_pb:stop_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Input) -> - stop_domain(ctx:new(), Input, #{}). - --spec stop_domain(ctx:t() | controller_pb:stop_domain_request(), controller_pb:stop_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Ctx, Input) when ?is_ctx(Ctx) -> - stop_domain(Ctx, Input, #{}); -stop_domain(Input, Options) -> - stop_domain(ctx:new(), Input, Options). - --spec stop_domain(ctx:t(), controller_pb:stop_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -stop_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/StopDomain">>, Input, ?DEF(stop_domain_request, empty, <<"StopDomainRequest">>), Options). - -%% @doc Unary RPC --spec get_domain(controller_pb:get_domain_request()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Input) -> - get_domain(ctx:new(), Input, #{}). - --spec get_domain(ctx:t() | controller_pb:get_domain_request(), controller_pb:get_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input) when ?is_ctx(Ctx) -> - get_domain(Ctx, Input, #{}); -get_domain(Input, Options) -> - get_domain(ctx:new(), Input, Options). - --spec get_domain(ctx:t(), controller_pb:get_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). - -%% @doc Unary RPC --spec list_domains(controller_pb:list_domains_request()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Input) -> - list_domains(ctx:new(), Input, #{}). - --spec list_domains(ctx:t() | controller_pb:list_domains_request(), controller_pb:list_domains_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input) when ?is_ctx(Ctx) -> - list_domains(Ctx, Input, #{}); -list_domains(Input, Options) -> - list_domains(ctx:new(), Input, Options). - --spec list_domains(ctx:t(), controller_pb:list_domains_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). - -%% @doc Unary RPC --spec create_domain(controller_pb:create_domain_request()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Input) -> - create_domain(ctx:new(), Input, #{}). - --spec create_domain(ctx:t() | controller_pb:create_domain_request(), controller_pb:create_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input) when ?is_ctx(Ctx) -> - create_domain(Ctx, Input, #{}); -create_domain(Input, Options) -> - create_domain(ctx:new(), Input, Options). - --spec create_domain(ctx:t(), controller_pb:create_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). - -%% @doc Unary RPC --spec delete_domain(controller_pb:delete_domain_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Input) -> - delete_domain(ctx:new(), Input, #{}). - --spec delete_domain(ctx:t() | controller_pb:delete_domain_request(), controller_pb:delete_domain_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> - delete_domain(Ctx, Input, #{}); -delete_domain(Input, Options) -> - delete_domain(ctx:new(), Input, Options). - --spec delete_domain(ctx:t(), controller_pb:delete_domain_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). - -%% @doc --spec download_image(controller_pb:download_image_request()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Input) -> - download_image(ctx:new(), Input, #{}). - --spec download_image(ctx:t() | controller_pb:download_image_request(), controller_pb:download_image_request() | grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input) when ?is_ctx(Ctx) -> - download_image(Ctx, Input, #{}); -download_image(Input, Options) -> - download_image(ctx:new(), Input, Options). - --spec download_image(ctx:t(), controller_pb:download_image_request(), grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input, Options) -> - grpcbox_client:stream(Ctx, <<"/DaemonService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). - -%% @doc Unary RPC --spec get_volume(controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Input) -> - get_volume(ctx:new(), Input, #{}). - --spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume(Ctx, Input, #{}); -get_volume(Input, Options) -> - get_volume(ctx:new(), Input, Options). - --spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volumes(controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Input) -> - list_volumes(ctx:new(), Input, #{}). - --spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> - list_volumes(Ctx, Input, #{}); -list_volumes(Input, Options) -> - list_volumes(ctx:new(), Input, Options). - --spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). - -%% @doc Unary RPC --spec create_volume(controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Input) -> - create_volume(ctx:new(), Input, #{}). - --spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input) when ?is_ctx(Ctx) -> - create_volume(Ctx, Input, #{}); -create_volume(Input, Options) -> - create_volume(ctx:new(), Input, Options). - --spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec update_volume(controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Input) -> - update_volume(ctx:new(), Input, #{}). - --spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input) when ?is_ctx(Ctx) -> - update_volume(Ctx, Input, #{}); -update_volume(Input, Options) -> - update_volume(ctx:new(), Input, Options). - --spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec delete_volume(controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Input) -> - delete_volume(ctx:new(), Input, #{}). - --spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> - delete_volume(Ctx, Input, #{}); -delete_volume(Input, Options) -> - delete_volume(ctx:new(), Input, Options). - --spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Input) -> - list_volume_attachments(ctx:new(), Input, #{}). - --spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> - list_volume_attachments(Ctx, Input, #{}); -list_volume_attachments(Input, Options) -> - list_volume_attachments(ctx:new(), Input, Options). - --spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). - -%% @doc Unary RPC --spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Input) -> - get_volume_attachment(ctx:new(), Input, #{}). - --spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume_attachment(Ctx, Input, #{}); -get_volume_attachment(Input, Options) -> - get_volume_attachment(ctx:new(), Input, Options). - --spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec attach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Input) -> - attach_volume(ctx:new(), Input, #{}). - --spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - attach_volume(Ctx, Input, #{}); -attach_volume(Input, Options) -> - attach_volume(ctx:new(), Input, Options). - --spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec detach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Input) -> - detach_volume(ctx:new(), Input, #{}). - --spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - detach_volume(Ctx, Input, #{}); -detach_volume(Input, Options) -> - detach_volume(ctx:new(), Input, Options). - --spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec get_port_forwarding(controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Input) -> - get_port_forwarding(ctx:new(), Input, #{}). - --spec get_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - get_port_forwarding(Ctx, Input, #{}); -get_port_forwarding(Input, Options) -> - get_port_forwarding(ctx:new(), Input, Options). - --spec get_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). - -%% @doc Unary RPC --spec list_port_forwardings(controller_pb:list_port_forwardings_request()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Input) -> - list_port_forwardings(ctx:new(), Input, #{}). - --spec list_port_forwardings(ctx:t() | controller_pb:list_port_forwardings_request(), controller_pb:list_port_forwardings_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> - list_port_forwardings(Ctx, Input, #{}); -list_port_forwardings(Input, Options) -> - list_port_forwardings(ctx:new(), Input, Options). - --spec list_port_forwardings(ctx:t(), controller_pb:list_port_forwardings_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). - -%% @doc Unary RPC --spec put_port_forwarding(controller_pb:put_port_forwarding_request()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Input) -> - put_port_forwarding(ctx:new(), Input, #{}). - --spec put_port_forwarding(ctx:t() | controller_pb:put_port_forwarding_request(), controller_pb:put_port_forwarding_request() | grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - put_port_forwarding(Ctx, Input, #{}); -put_port_forwarding(Input, Options) -> - put_port_forwarding(ctx:new(), Input, Options). - --spec put_port_forwarding(ctx:t(), controller_pb:put_port_forwarding_request(), grpcbox_client:options()) -> - {ok, controller_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). - -%% @doc Unary RPC --spec delete_port_forwarding(controller_pb:port_forwarding_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Input) -> - delete_port_forwarding(ctx:new(), Input, #{}). - --spec delete_port_forwarding(ctx:t() | controller_pb:port_forwarding_identifier(), controller_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - delete_port_forwarding(Ctx, Input, #{}); -delete_port_forwarding(Input, Options) -> - delete_port_forwarding(ctx:new(), Input, Options). - --spec delete_port_forwarding(ctx:t(), controller_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). - -%% @doc Unary RPC --spec sync_routes(controller_pb:sync_routes_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Input) -> - sync_routes(ctx:new(), Input, #{}). - --spec sync_routes(ctx:t() | controller_pb:sync_routes_request(), controller_pb:sync_routes_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Ctx, Input) when ?is_ctx(Ctx) -> - sync_routes(Ctx, Input, #{}); -sync_routes(Input, Options) -> - sync_routes(ctx:new(), Input, Options). - --spec sync_routes(ctx:t(), controller_pb:sync_routes_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync_routes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DaemonService/SyncRoutes">>, Input, ?DEF(sync_routes_request, empty, <<"SyncRoutesRequest">>), Options). - diff --git a/virtuerl/src/pb/dns_bhvr.erl b/virtuerl/src/pb/dns_bhvr.erl deleted file mode 100644 index 6c26475..0000000 --- a/virtuerl/src/pb/dns_bhvr.erl +++ /dev/null @@ -1,25 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service DNS. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(dns_bhvr). - -%% Unary RPC --callback get_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> - {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_dns_records(ctx:t(), controller_pb:list_dns_records_request()) -> - {ok, controller_pb:list_dns_records_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_dns_record(ctx:t(), controller_pb:put_dns_record_request()) -> - {ok, controller_pb:dns_record(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_dns_record(ctx:t(), controller_pb:dns_record_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/dns_client.erl b/virtuerl/src/pb/dns_client.erl deleted file mode 100644 index 527d371..0000000 --- a/virtuerl/src/pb/dns_client.erl +++ /dev/null @@ -1,97 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service DNS. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(dns_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'DNS'). --define(PROTO_MODULE, 'controller_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_dns_record(controller_pb:dns_record_identifier()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Input) -> - get_dns_record(ctx:new(), Input, #{}). - --spec get_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - get_dns_record(Ctx, Input, #{}); -get_dns_record(Input, Options) -> - get_dns_record(ctx:new(), Input, Options). - --spec get_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DNS/GetDNSRecord">>, Input, ?DEF(dns_record_identifier, dns_record, <<"DNSRecordIdentifier">>), Options). - -%% @doc Unary RPC --spec list_dns_records(controller_pb:list_dns_records_request()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Input) -> - list_dns_records(ctx:new(), Input, #{}). - --spec list_dns_records(ctx:t() | controller_pb:list_dns_records_request(), controller_pb:list_dns_records_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Ctx, Input) when ?is_ctx(Ctx) -> - list_dns_records(Ctx, Input, #{}); -list_dns_records(Input, Options) -> - list_dns_records(ctx:new(), Input, Options). - --spec list_dns_records(ctx:t(), controller_pb:list_dns_records_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_dns_records_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_dns_records(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DNS/ListDNSRecords">>, Input, ?DEF(list_dns_records_request, list_dns_records_response, <<"ListDNSRecordsRequest">>), Options). - -%% @doc Unary RPC --spec put_dns_record(controller_pb:put_dns_record_request()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Input) -> - put_dns_record(ctx:new(), Input, #{}). - --spec put_dns_record(ctx:t() | controller_pb:put_dns_record_request(), controller_pb:put_dns_record_request() | grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - put_dns_record(Ctx, Input, #{}); -put_dns_record(Input, Options) -> - put_dns_record(ctx:new(), Input, Options). - --spec put_dns_record(ctx:t(), controller_pb:put_dns_record_request(), grpcbox_client:options()) -> - {ok, controller_pb:dns_record(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DNS/PutDNSRecord">>, Input, ?DEF(put_dns_record_request, dns_record, <<"PutDNSRecordRequest">>), Options). - -%% @doc Unary RPC --spec delete_dns_record(controller_pb:dns_record_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Input) -> - delete_dns_record(ctx:new(), Input, #{}). - --spec delete_dns_record(ctx:t() | controller_pb:dns_record_identifier(), controller_pb:dns_record_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Ctx, Input) when ?is_ctx(Ctx) -> - delete_dns_record(Ctx, Input, #{}); -delete_dns_record(Input, Options) -> - delete_dns_record(ctx:new(), Input, Options). - --spec delete_dns_record(ctx:t(), controller_pb:dns_record_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_dns_record(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DNS/DeleteDNSRecord">>, Input, ?DEF(dns_record_identifier, empty, <<"DNSRecordIdentifier">>), Options). - diff --git a/virtuerl/src/pb/dns_pb.erl b/virtuerl/src/pb/dns_pb.erl deleted file mode 100644 index 3f91d8a..0000000 --- a/virtuerl/src/pb/dns_pb.erl +++ /dev/null @@ -1,1228 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(dns_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type dns_record_identifier() :: - #{name => unicode:chardata(), % = 1, optional - type => unicode:chardata() % = 2, optional - }. - --type dns_record() :: - #{name => unicode:chardata(), % = 1, optional - type => unicode:chardata(), % = 2, optional - ttl => non_neg_integer(), % = 3, optional, 64 bits - records => [unicode:chardata()] % = 4, repeated - }. - --type list_dns_records_request() :: - #{ - }. - --type list_dns_records_response() :: - #{dns_records => [dns_record()] % = 1, repeated - }. - --type put_dns_record_request() :: - #{dns_record => dns_record() % = 1, optional - }. - --type empty() :: - #{ - }. - --export_type(['dns_record_identifier'/0, 'dns_record'/0, 'list_dns_records_request'/0, 'list_dns_records_response'/0, 'put_dns_record_request'/0, 'empty'/0]). --type '$msg_name'() :: dns_record_identifier | dns_record | list_dns_records_request | list_dns_records_response | put_dns_record_request | empty. --type '$msg'() :: dns_record_identifier() | dns_record() | list_dns_records_request() | list_dns_records_response() | put_dns_record_request() | empty(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - dns_record_identifier -> encode_msg_dns_record_identifier(id(Msg, TrUserData), TrUserData); - dns_record -> encode_msg_dns_record(id(Msg, TrUserData), TrUserData); - list_dns_records_request -> encode_msg_list_dns_records_request(id(Msg, TrUserData), TrUserData); - list_dns_records_response -> encode_msg_list_dns_records_response(id(Msg, TrUserData), TrUserData); - put_dns_record_request -> encode_msg_put_dns_record_request(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_dns_record_identifier(Msg, TrUserData) -> encode_msg_dns_record_identifier(Msg, <<>>, TrUserData). - - -encode_msg_dns_record_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{type := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_dns_record(Msg, TrUserData) -> encode_msg_dns_record(Msg, <<>>, TrUserData). - - -encode_msg_dns_record(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{type := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{ttl := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{records := F4} -> - TrF4 = id(F4, TrUserData), - if TrF4 == [] -> B3; - true -> e_field_dns_record_records(TrF4, B3, TrUserData) - end; - _ -> B3 - end. - -encode_msg_list_dns_records_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_list_dns_records_response(Msg, TrUserData) -> encode_msg_list_dns_records_response(Msg, <<>>, TrUserData). - - -encode_msg_list_dns_records_response(#{} = M, Bin, TrUserData) -> - case M of - #{dns_records := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_dns_records_response_dns_records(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_dns_record_request(Msg, TrUserData) -> encode_msg_put_dns_record_request(Msg, <<>>, TrUserData). - - -encode_msg_put_dns_record_request(#{} = M, Bin, TrUserData) -> - case M of - #{dns_record := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_dns_record_request_dns_record(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -e_field_dns_record_records([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), - e_field_dns_record_records(Rest, Bin3, TrUserData); -e_field_dns_record_records([], Bin, _TrUserData) -> Bin. - -e_mfield_list_dns_records_response_dns_records(Msg, Bin, TrUserData) -> - SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_dns_records_response_dns_records([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_dns_records_response_dns_records(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_dns_records_response_dns_records(Rest, Bin3, TrUserData); -e_field_list_dns_records_response_dns_records([], Bin, _TrUserData) -> Bin. - -e_mfield_put_dns_record_request_dns_record(Msg, Bin, TrUserData) -> - SubBin = encode_msg_dns_record(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(dns_record_identifier, Bin, TrUserData) -> id(decode_msg_dns_record_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(dns_record, Bin, TrUserData) -> id(decode_msg_dns_record(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_dns_records_request, Bin, TrUserData) -> id(decode_msg_list_dns_records_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_dns_records_response, Bin, TrUserData) -> id(decode_msg_list_dns_records_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_dns_record_request, Bin, TrUserData) -> id(decode_msg_put_dns_record_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). - - - -decode_msg_dns_record_identifier(Bin, TrUserData) -> dfp_read_field_def_dns_record_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_dns_record_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_dns_record_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_dns_record_identifier_type(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}; -dfp_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_dns_record_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_dns_record_identifier_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_dns_record_identifier_type(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_dns_record_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_dns_record_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, type => F@_2}. - -d_field_dns_record_identifier_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_dns_record_identifier_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_dns_record_identifier_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_dns_record_identifier_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_dns_record_identifier_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_dns_record_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_dns_record_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_dns_record_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_dns_record_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_dns_record_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_dns_record_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_dns_record_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_dns_record_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_dns_record_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_dns_record_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_dns_record_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_dns_record(Bin, TrUserData) -> dfp_read_field_def_dns_record(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id([], TrUserData), TrUserData). - -dfp_read_field_def_dns_record(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_ttl(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_dns_record_records(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}; -dfp_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_dns_record(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_dns_record_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 18 -> d_field_dns_record_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 24 -> d_field_dns_record_ttl(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_dns_record_records(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_dns_record(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_dns_record(<<>>, 0, 0, _, F@_1, F@_2, F@_3, R1, TrUserData) -> #{name => F@_1, type => F@_2, ttl => F@_3, records => lists_reverse(R1, TrUserData)}. - -d_field_dns_record_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_dns_record_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_dns_record_ttl(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_ttl(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_ttl(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_dns_record_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_dns_record_records(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_dns_record_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_dns_record(RestF, 0, 0, F, F@_1, F@_2, F@_3, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_dns_record(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_dns_record(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_dns_record(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_dns_record(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_dns_record(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_dns_record(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_dns_record(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_dns_record(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_dns_records_request(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_dns_records_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_list_dns_records_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_list_dns_records_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_list_dns_records_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_dns_records_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_list_dns_records_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_list_dns_records_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_list_dns_records_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_dns_records_request(Rest2, 0, 0, F, TrUserData). - -skip_group_list_dns_records_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_dns_records_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_list_dns_records_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_list_dns_records_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_dns_records_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_list_dns_records_response(Bin, TrUserData) -> dfp_read_field_def_list_dns_records_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_dns_records_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_dns_records_response_dns_records(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{dns_records => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_dns_records_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_dns_records_response_dns_records(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_dns_records_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_dns_records_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{dns_records => lists_reverse(R1, TrUserData)} - end. - -d_field_list_dns_records_response_dns_records(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_dns_records_response_dns_records(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_dns_records_response_dns_records(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_dns_records_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_dns_records_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_dns_records_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_dns_records_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_dns_records_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_dns_records_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_dns_records_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_dns_records_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_dns_records_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_dns_records_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_dns_records_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_dns_records_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_dns_record_request(Bin, TrUserData) -> dfp_read_field_def_put_dns_record_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_put_dns_record_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_dns_record_request_dns_record(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{dns_record => F@_1} - end; -dfp_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_dns_record_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_dns_record_request_dns_record(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_put_dns_record_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_put_dns_record_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{dns_record => F@_1} - end. - -d_field_put_dns_record_request_dns_record(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_dns_record_request_dns_record(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_put_dns_record_request_dns_record(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_dns_record(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_dns_record_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_dns_record(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_put_dns_record_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_put_dns_record_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_put_dns_record_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_dns_record_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_put_dns_record_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_dns_record_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_put_dns_record_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_dns_record_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_put_dns_record_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_put_dns_record_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_dns_record_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - dns_record_identifier -> merge_msg_dns_record_identifier(Prev, New, TrUserData); - dns_record -> merge_msg_dns_record(Prev, New, TrUserData); - list_dns_records_request -> merge_msg_list_dns_records_request(Prev, New, TrUserData); - list_dns_records_response -> merge_msg_list_dns_records_response(Prev, New, TrUserData); - put_dns_record_request -> merge_msg_put_dns_record_request(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_dns_record_identifier/3}). -merge_msg_dns_record_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S2#{type => NFtype}; - {#{type := PFtype}, _} -> S2#{type => PFtype}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_dns_record/3}). -merge_msg_dns_record(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{type := NFtype}} -> S2#{type => NFtype}; - {#{type := PFtype}, _} -> S2#{type => PFtype}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{ttl := NFttl}} -> S3#{ttl => NFttl}; - {#{ttl := PFttl}, _} -> S3#{ttl => PFttl}; - _ -> S3 - end, - case {PMsg, NMsg} of - {#{records := PFrecords}, #{records := NFrecords}} -> S4#{records => 'erlang_++'(PFrecords, NFrecords, TrUserData)}; - {_, #{records := NFrecords}} -> S4#{records => NFrecords}; - {#{records := PFrecords}, _} -> S4#{records => PFrecords}; - {_, _} -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_dns_records_request/3}). -merge_msg_list_dns_records_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_list_dns_records_response/3}). -merge_msg_list_dns_records_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{dns_records := PFdns_records}, #{dns_records := NFdns_records}} -> S1#{dns_records => 'erlang_++'(PFdns_records, NFdns_records, TrUserData)}; - {_, #{dns_records := NFdns_records}} -> S1#{dns_records => NFdns_records}; - {#{dns_records := PFdns_records}, _} -> S1#{dns_records => PFdns_records}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_dns_record_request/3}). -merge_msg_put_dns_record_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{dns_record := PFdns_record}, #{dns_record := NFdns_record}} -> S1#{dns_record => merge_msg_dns_record(PFdns_record, NFdns_record, TrUserData)}; - {_, #{dns_record := NFdns_record}} -> S1#{dns_record => NFdns_record}; - {#{dns_record := PFdns_record}, _} -> S1#{dns_record => PFdns_record}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - dns_record_identifier -> v_msg_dns_record_identifier(Msg, [MsgName], TrUserData); - dns_record -> v_msg_dns_record(Msg, [MsgName], TrUserData); - list_dns_records_request -> v_msg_list_dns_records_request(Msg, [MsgName], TrUserData); - list_dns_records_response -> v_msg_list_dns_records_response(Msg, [MsgName], TrUserData); - put_dns_record_request -> v_msg_put_dns_record_request(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_dns_record_identifier/3}). --dialyzer({nowarn_function,v_msg_dns_record_identifier/3}). -v_msg_dns_record_identifier(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (type) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_dns_record_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record_identifier}, M, Path); -v_msg_dns_record_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_dns_record/3}). --dialyzer({nowarn_function,v_msg_dns_record/3}). -v_msg_dns_record(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{type := F2} -> v_type_string(F2, [type | Path], TrUserData); - _ -> ok - end, - case M of - #{ttl := F3} -> v_type_uint64(F3, [ttl | Path], TrUserData); - _ -> ok - end, - case M of - #{records := F4} -> - if is_list(F4) -> - _ = [v_type_string(Elem, [records | Path], TrUserData) || Elem <- F4], - ok; - true -> mk_type_error({invalid_list_of, string}, F4, [records | Path]) - end; - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (type) -> ok; - (ttl) -> ok; - (records) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_dns_record(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), dns_record}, M, Path); -v_msg_dns_record(X, Path, _TrUserData) -> mk_type_error({expected_msg, dns_record}, X, Path). - --compile({nowarn_unused_function,v_msg_list_dns_records_request/3}). --dialyzer({nowarn_function,v_msg_list_dns_records_request/3}). -v_msg_list_dns_records_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_list_dns_records_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_request}, M, Path); -v_msg_list_dns_records_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_dns_records_response/3}). --dialyzer({nowarn_function,v_msg_list_dns_records_response/3}). -v_msg_list_dns_records_response(#{} = M, Path, TrUserData) -> - case M of - #{dns_records := F1} -> - if is_list(F1) -> - _ = [v_msg_dns_record(Elem, [dns_records | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, dns_record}}, F1, [dns_records | Path]) - end; - _ -> ok - end, - lists:foreach(fun (dns_records) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_dns_records_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_dns_records_response}, M, Path); -v_msg_list_dns_records_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_dns_records_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_dns_record_request/3}). --dialyzer({nowarn_function,v_msg_put_dns_record_request/3}). -v_msg_put_dns_record_request(#{} = M, Path, TrUserData) -> - case M of - #{dns_record := F1} -> v_msg_dns_record(F1, [dns_record | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (dns_record) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_dns_record_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_dns_record_request}, M, Path); -v_msg_put_dns_record_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_dns_record_request}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; -v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); -v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, dns_record_identifier}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, dns_record}, - [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, - #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]}, - {{msg, list_dns_records_request}, []}, - {{msg, list_dns_records_response}, [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]}, - {{msg, put_dns_record_request}, [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]}, - {{msg, empty}, []}]. - - -get_msg_names() -> [dns_record_identifier, dns_record, list_dns_records_request, list_dns_records_response, put_dns_record_request, empty]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> [dns_record_identifier, dns_record, list_dns_records_request, list_dns_records_response, put_dns_record_request, empty]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(dns_record_identifier) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(dns_record) -> - [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => type, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => ttl, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}, - #{name => records, fnum => 4, rnum => 5, type => string, occurrence => repeated, opts => []}]; -find_msg_def(list_dns_records_request) -> []; -find_msg_def(list_dns_records_response) -> [#{name => dns_records, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => repeated, opts => []}]; -find_msg_def(put_dns_record_request) -> [#{name => dns_record, fnum => 1, rnum => 2, type => {msg, dns_record}, occurrence => optional, opts => []}]; -find_msg_def(empty) -> []; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['DNS']. - - -get_service_def('DNS') -> - {{service, 'DNS'}, - [#{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('DNS') -> ['GetDNSRecord', 'ListDNSRecords', 'PutDNSRecord', 'DeleteDNSRecord']; -get_rpc_names(_) -> error. - - -find_rpc_def('DNS', RpcName) -> find_rpc_def_DNS(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_DNS('GetDNSRecord') -> #{name => 'GetDNSRecord', input => dns_record_identifier, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('ListDNSRecords') -> #{name => 'ListDNSRecords', input => list_dns_records_request, output => list_dns_records_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('PutDNSRecord') -> #{name => 'PutDNSRecord', input => put_dns_record_request, output => dns_record, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS('DeleteDNSRecord') -> #{name => 'DeleteDNSRecord', input => dns_record_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DNS(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"DNS">>) -> 'DNS'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('DNS') -> <<"DNS">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"GetDNSRecord">>) -> {'DNS', 'GetDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"ListDNSRecords">>) -> {'DNS', 'ListDNSRecords'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"PutDNSRecord">>) -> {'DNS', 'PutDNSRecord'}; -fqbins_to_service_and_rpc_name(<<"DNS">>, <<"DeleteDNSRecord">>) -> {'DNS', 'DeleteDNSRecord'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('DNS', 'GetDNSRecord') -> {<<"DNS">>, <<"GetDNSRecord">>}; -service_and_rpc_name_to_fqbins('DNS', 'ListDNSRecords') -> {<<"DNS">>, <<"ListDNSRecords">>}; -service_and_rpc_name_to_fqbins('DNS', 'PutDNSRecord') -> {<<"DNS">>, <<"PutDNSRecord">>}; -service_and_rpc_name_to_fqbins('DNS', 'DeleteDNSRecord') -> {<<"DNS">>, <<"DeleteDNSRecord">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"DNSRecordIdentifier">>) -> dns_record_identifier; -fqbin_to_msg_name(<<"DNSRecord">>) -> dns_record; -fqbin_to_msg_name(<<"ListDNSRecordsRequest">>) -> list_dns_records_request; -fqbin_to_msg_name(<<"ListDNSRecordsResponse">>) -> list_dns_records_response; -fqbin_to_msg_name(<<"PutDNSRecordRequest">>) -> put_dns_record_request; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(dns_record_identifier) -> <<"DNSRecordIdentifier">>; -msg_name_to_fqbin(dns_record) -> <<"DNSRecord">>; -msg_name_to_fqbin(list_dns_records_request) -> <<"ListDNSRecordsRequest">>; -msg_name_to_fqbin(list_dns_records_response) -> <<"ListDNSRecordsResponse">>; -msg_name_to_fqbin(put_dns_record_request) -> <<"PutDNSRecordRequest">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "dns.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["dns.proto", "empty.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["dns", "empty"]. - - -get_msg_containment("dns") -> [dns_record, dns_record_identifier, list_dns_records_request, list_dns_records_response, put_dns_record_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("dns") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("dns") -> ['DNS']; -get_service_containment("empty") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("dns") -> [{'DNS', 'GetDNSRecord'}, {'DNS', 'ListDNSRecords'}, {'DNS', 'PutDNSRecord'}, {'DNS', 'DeleteDNSRecord'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("dns") -> []; -get_enum_containment("empty") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"DNSRecordIdentifier">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"PutDNSRecordRequest">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsRequest">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"DNSRecord">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"ListDNSRecordsResponse">>) -> "dns"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"DNS">>) -> "dns"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/domain_pb.erl b/virtuerl/src/pb/domain_pb.erl deleted file mode 100644 index 70aab16..0000000 --- a/virtuerl/src/pb/domain_pb.erl +++ /dev/null @@ -1,3401 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(domain_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type start_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata() % = 2, optional - }. - --type stop_domain_request() :: - #{host => unicode:chardata(), % = 1, optional - uuid => unicode:chardata(), % = 2, optional - force => boolean() | 0 | 1 % = 3, optional - }. - --type get_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type domain() :: - #{id => non_neg_integer(), % = 1, optional, 64 bits - uuid => unicode:chardata(), % = 2, optional - name => unicode:chardata(), % = 3, optional - vcpu => non_neg_integer(), % = 4, optional, 32 bits - memory => non_neg_integer(), % = 5, optional, 64 bits - network => unicode:chardata(), % = 6, optional - bridge => unicode:chardata(), % = 7, optional - state => unicode:chardata(), % = 8, optional - private_ip => unicode:chardata(), % = 9, optional - ipv6_address => unicode:chardata(), % = 15, optional - user_data => unicode:chardata(), % = 10, optional - nested_virtualization => boolean() | 0 | 1, % = 11, optional - base_image => unicode:chardata(), % = 12, optional - created_at => timestamp(), % = 13, optional - os_type => unicode:chardata() % = 14, optional - }. - --type list_domains_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_domains_response() :: - #{domains => [domain()] % = 1, repeated - }. - --type create_domain_request() :: - #{domain => domain(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_domain_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type download_image_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type image_chunk() :: - #{bytes => iodata() % = 1, optional - }. - --type get_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type network() :: - #{uuid => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - cidr => unicode:chardata(), % = 3, optional - cidr6 => unicode:chardata() % = 4, optional - }. - --type list_networks_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_networks_response() :: - #{networks => [network()] % = 1, repeated - }. - --type create_network_request() :: - #{network => network(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type delete_network_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type empty() :: - #{ - }. - --type timestamp() :: - #{seconds => integer(), % = 1, optional, 64 bits - nanos => integer() % = 2, optional, 32 bits - }. - --export_type(['start_domain_request'/0, 'stop_domain_request'/0, 'get_domain_request'/0, 'domain'/0, 'list_domains_request'/0, 'list_domains_response'/0, 'create_domain_request'/0, 'delete_domain_request'/0, 'download_image_request'/0, 'image_chunk'/0, 'get_network_request'/0, 'network'/0, 'list_networks_request'/0, 'list_networks_response'/0, 'create_network_request'/0, 'delete_network_request'/0, 'empty'/0, 'timestamp'/0]). --type '$msg_name'() :: start_domain_request | stop_domain_request | get_domain_request | domain | list_domains_request | list_domains_response | create_domain_request | delete_domain_request | download_image_request | image_chunk | get_network_request | network | list_networks_request | list_networks_response | create_network_request | delete_network_request | empty | timestamp. --type '$msg'() :: start_domain_request() | stop_domain_request() | get_domain_request() | domain() | list_domains_request() | list_domains_response() | create_domain_request() | delete_domain_request() | download_image_request() | image_chunk() | get_network_request() | network() | list_networks_request() | list_networks_response() | create_network_request() | delete_network_request() | empty() | timestamp(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - start_domain_request -> encode_msg_start_domain_request(id(Msg, TrUserData), TrUserData); - stop_domain_request -> encode_msg_stop_domain_request(id(Msg, TrUserData), TrUserData); - get_domain_request -> encode_msg_get_domain_request(id(Msg, TrUserData), TrUserData); - domain -> encode_msg_domain(id(Msg, TrUserData), TrUserData); - list_domains_request -> encode_msg_list_domains_request(id(Msg, TrUserData), TrUserData); - list_domains_response -> encode_msg_list_domains_response(id(Msg, TrUserData), TrUserData); - create_domain_request -> encode_msg_create_domain_request(id(Msg, TrUserData), TrUserData); - delete_domain_request -> encode_msg_delete_domain_request(id(Msg, TrUserData), TrUserData); - download_image_request -> encode_msg_download_image_request(id(Msg, TrUserData), TrUserData); - image_chunk -> encode_msg_image_chunk(id(Msg, TrUserData), TrUserData); - get_network_request -> encode_msg_get_network_request(id(Msg, TrUserData), TrUserData); - network -> encode_msg_network(id(Msg, TrUserData), TrUserData); - list_networks_request -> encode_msg_list_networks_request(id(Msg, TrUserData), TrUserData); - list_networks_response -> encode_msg_list_networks_response(id(Msg, TrUserData), TrUserData); - create_network_request -> encode_msg_create_network_request(id(Msg, TrUserData), TrUserData); - delete_network_request -> encode_msg_delete_network_request(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); - timestamp -> encode_msg_timestamp(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_start_domain_request(Msg, TrUserData) -> encode_msg_start_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_start_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_stop_domain_request(Msg, TrUserData) -> encode_msg_stop_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_stop_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{force := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= false -> B2; - true -> e_type_bool(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_get_domain_request(Msg, TrUserData) -> encode_msg_get_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_get_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_domain(Msg, TrUserData) -> encode_msg_domain(Msg, <<>>, TrUserData). - - -encode_msg_domain(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{uuid := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{name := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - B4 = case M of - #{vcpu := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end, - B5 = case M of - #{memory := F5} -> - begin - TrF5 = id(F5, TrUserData), - if TrF5 =:= 0 -> B4; - true -> e_varint(TrF5, <>, TrUserData) - end - end; - _ -> B4 - end, - B6 = case M of - #{network := F6} -> - begin - TrF6 = id(F6, TrUserData), - case is_empty_string(TrF6) of - true -> B5; - false -> e_type_string(TrF6, <>, TrUserData) - end - end; - _ -> B5 - end, - B7 = case M of - #{bridge := F7} -> - begin - TrF7 = id(F7, TrUserData), - case is_empty_string(TrF7) of - true -> B6; - false -> e_type_string(TrF7, <>, TrUserData) - end - end; - _ -> B6 - end, - B8 = case M of - #{state := F8} -> - begin - TrF8 = id(F8, TrUserData), - case is_empty_string(TrF8) of - true -> B7; - false -> e_type_string(TrF8, <>, TrUserData) - end - end; - _ -> B7 - end, - B9 = case M of - #{private_ip := F9} -> - begin - TrF9 = id(F9, TrUserData), - case is_empty_string(TrF9) of - true -> B8; - false -> e_type_string(TrF9, <>, TrUserData) - end - end; - _ -> B8 - end, - B10 = case M of - #{ipv6_address := F10} -> - begin - TrF10 = id(F10, TrUserData), - case is_empty_string(TrF10) of - true -> B9; - false -> e_type_string(TrF10, <>, TrUserData) - end - end; - _ -> B9 - end, - B11 = case M of - #{user_data := F11} -> - begin - TrF11 = id(F11, TrUserData), - case is_empty_string(TrF11) of - true -> B10; - false -> e_type_string(TrF11, <>, TrUserData) - end - end; - _ -> B10 - end, - B12 = case M of - #{nested_virtualization := F12} -> - begin - TrF12 = id(F12, TrUserData), - if TrF12 =:= false -> B11; - true -> e_type_bool(TrF12, <>, TrUserData) - end - end; - _ -> B11 - end, - B13 = case M of - #{base_image := F13} -> - begin - TrF13 = id(F13, TrUserData), - case is_empty_string(TrF13) of - true -> B12; - false -> e_type_string(TrF13, <>, TrUserData) - end - end; - _ -> B12 - end, - B14 = case M of - #{created_at := F14} -> - begin - TrF14 = id(F14, TrUserData), - if TrF14 =:= undefined -> B13; - true -> e_mfield_domain_created_at(TrF14, <>, TrUserData) - end - end; - _ -> B13 - end, - case M of - #{os_type := F15} -> - begin - TrF15 = id(F15, TrUserData), - case is_empty_string(TrF15) of - true -> B14; - false -> e_type_string(TrF15, <>, TrUserData) - end - end; - _ -> B14 - end. - -encode_msg_list_domains_request(Msg, TrUserData) -> encode_msg_list_domains_request(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_domains_response(Msg, TrUserData) -> encode_msg_list_domains_response(Msg, <<>>, TrUserData). - - -encode_msg_list_domains_response(#{} = M, Bin, TrUserData) -> - case M of - #{domains := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_domains_response_domains(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_domain_request(Msg, TrUserData) -> encode_msg_create_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_create_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_domain_request_domain(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_domain_request(Msg, TrUserData) -> encode_msg_delete_domain_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_domain_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_download_image_request(Msg, TrUserData) -> encode_msg_download_image_request(Msg, <<>>, TrUserData). - - -encode_msg_download_image_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_image_chunk(Msg, TrUserData) -> encode_msg_image_chunk(Msg, <<>>, TrUserData). - - -encode_msg_image_chunk(#{} = M, Bin, TrUserData) -> - case M of - #{bytes := F1} -> - begin - TrF1 = id(F1, TrUserData), - case iolist_size(TrF1) of - 0 -> Bin; - _ -> e_type_bytes(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_get_network_request(Msg, TrUserData) -> encode_msg_get_network_request(Msg, <<>>, TrUserData). - - -encode_msg_get_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_network(Msg, TrUserData) -> encode_msg_network(Msg, <<>>, TrUserData). - - -encode_msg_network(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{cidr := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{cidr6 := F4} -> - begin - TrF4 = id(F4, TrUserData), - case is_empty_string(TrF4) of - true -> B3; - false -> e_type_string(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_networks_request(Msg, TrUserData) -> encode_msg_list_networks_request(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_networks_response(Msg, TrUserData) -> encode_msg_list_networks_response(Msg, <<>>, TrUserData). - - -encode_msg_list_networks_response(#{} = M, Bin, TrUserData) -> - case M of - #{networks := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_networks_response_networks(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_network_request(Msg, TrUserData) -> encode_msg_create_network_request(Msg, <<>>, TrUserData). - - -encode_msg_create_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{network := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_network_request_network(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_network_request(Msg, TrUserData) -> encode_msg_delete_network_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_network_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -encode_msg_timestamp(Msg, TrUserData) -> encode_msg_timestamp(Msg, <<>>, TrUserData). - - -encode_msg_timestamp(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{seconds := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_type_int64(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{nanos := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_type_int32(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -e_mfield_domain_created_at(Msg, Bin, TrUserData) -> - SubBin = encode_msg_timestamp(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_domains_response_domains(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_domains_response_domains([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_domains_response_domains(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_domains_response_domains(Rest, Bin3, TrUserData); -e_field_list_domains_response_domains([], Bin, _TrUserData) -> Bin. - -e_mfield_create_domain_request_domain(Msg, Bin, TrUserData) -> - SubBin = encode_msg_domain(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_networks_response_networks(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_networks_response_networks([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_networks_response_networks(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_networks_response_networks(Rest, Bin3, TrUserData); -e_field_list_networks_response_networks([], Bin, _TrUserData) -> Bin. - -e_mfield_create_network_request_network(Msg, Bin, TrUserData) -> - SubBin = encode_msg_network(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(start_domain_request, Bin, TrUserData) -> id(decode_msg_start_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(stop_domain_request, Bin, TrUserData) -> id(decode_msg_stop_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_domain_request, Bin, TrUserData) -> id(decode_msg_get_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(domain, Bin, TrUserData) -> id(decode_msg_domain(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_request, Bin, TrUserData) -> id(decode_msg_list_domains_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_domains_response, Bin, TrUserData) -> id(decode_msg_list_domains_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_domain_request, Bin, TrUserData) -> id(decode_msg_create_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_domain_request, Bin, TrUserData) -> id(decode_msg_delete_domain_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(download_image_request, Bin, TrUserData) -> id(decode_msg_download_image_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(image_chunk, Bin, TrUserData) -> id(decode_msg_image_chunk(Bin, TrUserData), TrUserData); -decode_msg_2_doit(get_network_request, Bin, TrUserData) -> id(decode_msg_get_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(network, Bin, TrUserData) -> id(decode_msg_network(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_request, Bin, TrUserData) -> id(decode_msg_list_networks_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_networks_response, Bin, TrUserData) -> id(decode_msg_list_networks_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_network_request, Bin, TrUserData) -> id(decode_msg_create_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_network_request, Bin, TrUserData) -> id(decode_msg_delete_network_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); -decode_msg_2_doit(timestamp, Bin, TrUserData) -> id(decode_msg_timestamp(Bin, TrUserData), TrUserData). - - - -decode_msg_start_domain_request(Bin, TrUserData) -> dfp_read_field_def_start_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_start_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_start_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}; -dfp_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_start_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_start_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_start_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_start_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_start_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{host => F@_1, uuid => F@_2}. - -d_field_start_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_start_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_start_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_start_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_start_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_start_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_start_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_start_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_start_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_start_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_start_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_start_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_start_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_start_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_start_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_start_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_stop_domain_request(Bin, TrUserData) -> dfp_read_field_def_stop_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(false, TrUserData), TrUserData). - -dfp_read_field_def_stop_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_stop_domain_request_force(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}; -dfp_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_stop_domain_request(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_stop_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_stop_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_stop_domain_request_force(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_stop_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_stop_domain_request(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, uuid => F@_2, force => F@_3}. - -d_field_stop_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_stop_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_stop_domain_request_force(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_stop_domain_request_force(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_stop_domain_request_force(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_stop_domain_request(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_stop_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_stop_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_stop_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_stop_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_stop_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_stop_domain_request(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_stop_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_stop_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_stop_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_stop_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_stop_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_get_domain_request(Bin, TrUserData) -> dfp_read_field_def_get_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_domain(Bin, TrUserData) -> - dfp_read_field_def_domain(Bin, - 0, - 0, - 0, - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(0, TrUserData), - id(0, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(<<>>, TrUserData), - id(false, TrUserData), - id(<<>>, TrUserData), - id('$undef', TrUserData), - id(<<>>, TrUserData), - TrUserData). - -dfp_read_field_def_domain(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_vcpu(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_memory(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<50, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<58, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_bridge(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<66, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_state(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<74, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_private_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<122, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_ipv6_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<82, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_user_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<88, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_nested_virtualization(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<98, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_base_image(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<106, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_created_at(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<114, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - d_field_domain_os_type(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dfp_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end; -dfp_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dg_read_field_def_domain(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -dg_read_field_def_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 32 - 7 -> - dg_read_field_def_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -dg_read_field_def_domain(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 18 -> d_field_domain_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 26 -> d_field_domain_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 32 -> d_field_domain_vcpu(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 40 -> d_field_domain_memory(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 50 -> d_field_domain_network(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 58 -> d_field_domain_bridge(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 66 -> d_field_domain_state(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 74 -> d_field_domain_private_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 122 -> d_field_domain_ipv6_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 82 -> d_field_domain_user_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 88 -> d_field_domain_nested_virtualization(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 98 -> d_field_domain_base_image(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 106 -> d_field_domain_created_at(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 114 -> d_field_domain_os_type(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 1 -> skip_64_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 2 -> skip_length_delimited_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 3 -> skip_group_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); - 5 -> skip_32_domain(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) - end - end; -dg_read_field_def_domain(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, _) -> - S1 = #{id => F@_1, uuid => F@_2, name => F@_3, vcpu => F@_4, memory => F@_5, network => F@_6, bridge => F@_7, state => F@_8, private_ip => F@_9, ipv6_address => F@_10, user_data => F@_11, nested_virtualization => F@_12, base_image => F@_13, - os_type => F@_15}, - if F@_14 == '$undef' -> S1; - true -> S1#{created_at => F@_14} - end. - -d_field_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_vcpu(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_vcpu(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_vcpu(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_memory(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_memory(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_memory(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, _, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, NewFValue, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_bridge(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_bridge(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_bridge(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, _, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, NewFValue, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_state(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_state(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_state(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, _, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, NewFValue, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_private_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_private_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_private_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, NewFValue, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_ipv6_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_ipv6_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_ipv6_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, _, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, NewFValue, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_user_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_user_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_user_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, _, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, NewFValue, F@_12, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_nested_virtualization(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_nested_virtualization(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_nested_virtualization(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, _, F@_13, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, NewFValue, F@_13, F@_14, F@_15, TrUserData). - -d_field_domain_base_image(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_base_image(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_base_image(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, _, F@_14, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, NewFValue, F@_14, F@_15, TrUserData). - -d_field_domain_created_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_created_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_created_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, Prev, F@_15, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_timestamp(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, - 0, - 0, - F, - F@_1, - F@_2, - F@_3, - F@_4, - F@_5, - F@_6, - F@_7, - F@_8, - F@_9, - F@_10, - F@_11, - F@_12, - F@_13, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_timestamp(Prev, NewFValue, TrUserData) - end, - F@_15, - TrUserData). - -d_field_domain_os_type(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - d_field_domain_os_type(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -d_field_domain_os_type(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_domain(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, NewFValue, TrUserData). - -skip_varint_domain(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - skip_varint_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_varint_domain(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_length_delimited_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) when N < 57 -> - skip_length_delimited_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData); -skip_length_delimited_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_domain(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_group_domain(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_domain(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_32_domain(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -skip_64_domain(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData) -> - dfp_read_field_def_domain(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, F@_9, F@_10, F@_11, F@_12, F@_13, F@_14, F@_15, TrUserData). - -decode_msg_list_domains_request(Bin, TrUserData) -> dfp_read_field_def_list_domains_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_domains_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_domains_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_domains_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_domains_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_domains_response(Bin, TrUserData) -> dfp_read_field_def_list_domains_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_domains_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_domains_response_domains(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_domains_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_domains_response_domains(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_domains_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_domains_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{domains => lists_reverse(R1, TrUserData)} - end. - -d_field_list_domains_response_domains(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_domains_response_domains(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_domains_response_domains(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_domains_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_domains_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_domains_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_domains_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_domains_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_domains_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_domains_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_domains_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_domains_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_domains_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_domains_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_domains_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_domain_request(Bin, TrUserData) -> dfp_read_field_def_create_domain_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_domain(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end; -dfp_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_domain_request_domain(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{domain => F@_1} - end. - -d_field_create_domain_request_domain(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_domain(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_domain(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_domain(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_domain(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_domain_request(Bin, TrUserData) -> dfp_read_field_def_delete_domain_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_domain_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_domain_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_domain_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_domain_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_domain_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_domain_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_domain_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_domain_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_domain_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_domain_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_domain_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_domain_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_domain_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_domain_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_domain_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_domain_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_domain_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_domain_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_domain_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_domain_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_domain_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_domain_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_domain_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_download_image_request(Bin, TrUserData) -> dfp_read_field_def_download_image_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_download_image_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_download_image_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_download_image_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_download_image_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_download_image_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_download_image_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_download_image_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_download_image_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_download_image_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_download_image_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_download_image_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_download_image_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_download_image_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_download_image_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_download_image_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_download_image_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_download_image_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_download_image_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_download_image_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_download_image_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_download_image_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_download_image_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_download_image_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_image_chunk(Bin, TrUserData) -> dfp_read_field_def_image_chunk(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_image_chunk(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_image_chunk_bytes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}; -dfp_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_image_chunk(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_image_chunk_bytes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_image_chunk(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_image_chunk(<<>>, 0, 0, _, F@_1, _) -> #{bytes => F@_1}. - -d_field_image_chunk_bytes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_image_chunk_bytes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_image_chunk_bytes(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_image_chunk(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_image_chunk(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_image_chunk(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_image_chunk(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_image_chunk(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_image_chunk(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_image_chunk(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_image_chunk(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_image_chunk(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_image_chunk(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_image_chunk(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_image_chunk(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_get_network_request(Bin, TrUserData) -> dfp_read_field_def_get_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_network(Bin, TrUserData) -> dfp_read_field_def_network(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_network(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_uuid(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_network_cidr6(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}; -dfp_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_network(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_network(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_network_uuid(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 18 -> d_field_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 26 -> d_field_network_cidr(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_network_cidr6(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_network(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_network(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{uuid => F@_1, name => F@_2, cidr => F@_3, cidr6 => F@_4}. - -d_field_network_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_network_cidr(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_network_cidr6(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_network_cidr6(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_network_cidr6(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_network(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_network(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_network(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_network(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_network(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_network(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_network(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_network(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_network(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_networks_request(Bin, TrUserData) -> dfp_read_field_def_list_networks_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_networks_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_networks_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_networks_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_networks_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_networks_response(Bin, TrUserData) -> dfp_read_field_def_list_networks_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_networks_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_networks_response_networks(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_networks_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_networks_response_networks(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_networks_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_networks_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{networks => lists_reverse(R1, TrUserData)} - end. - -d_field_list_networks_response_networks(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_networks_response_networks(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_networks_response_networks(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_networks_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_networks_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_networks_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_networks_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_networks_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_networks_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_networks_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_networks_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_networks_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_networks_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_networks_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_networks_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_network_request(Bin, TrUserData) -> dfp_read_field_def_create_network_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_network(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end; -dfp_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_network_request_network(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{network => F@_1} - end. - -d_field_create_network_request_network(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_network(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_network(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_network(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_network(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_network_request(Bin, TrUserData) -> dfp_read_field_def_delete_network_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_network_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_network_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_network_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_network_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_network_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_network_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_network_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_network_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_network_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_network_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_network_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_network_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_network_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_network_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_network_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_network_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_network_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_network_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_network_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_network_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_network_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_network_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_network_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -decode_msg_timestamp(Bin, TrUserData) -> dfp_read_field_def_timestamp(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; -dfp_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 16 -> d_field_timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. - -d_field_timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, - dfp_read_field_def_timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - start_domain_request -> merge_msg_start_domain_request(Prev, New, TrUserData); - stop_domain_request -> merge_msg_stop_domain_request(Prev, New, TrUserData); - get_domain_request -> merge_msg_get_domain_request(Prev, New, TrUserData); - domain -> merge_msg_domain(Prev, New, TrUserData); - list_domains_request -> merge_msg_list_domains_request(Prev, New, TrUserData); - list_domains_response -> merge_msg_list_domains_response(Prev, New, TrUserData); - create_domain_request -> merge_msg_create_domain_request(Prev, New, TrUserData); - delete_domain_request -> merge_msg_delete_domain_request(Prev, New, TrUserData); - download_image_request -> merge_msg_download_image_request(Prev, New, TrUserData); - image_chunk -> merge_msg_image_chunk(Prev, New, TrUserData); - get_network_request -> merge_msg_get_network_request(Prev, New, TrUserData); - network -> merge_msg_network(Prev, New, TrUserData); - list_networks_request -> merge_msg_list_networks_request(Prev, New, TrUserData); - list_networks_response -> merge_msg_list_networks_response(Prev, New, TrUserData); - create_network_request -> merge_msg_create_network_request(Prev, New, TrUserData); - delete_network_request -> merge_msg_delete_network_request(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData); - timestamp -> merge_msg_timestamp(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_start_domain_request/3}). -merge_msg_start_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_stop_domain_request/3}). -merge_msg_stop_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{force := NFforce}} -> S3#{force => NFforce}; - {#{force := PFforce}, _} -> S3#{force => PFforce}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_get_domain_request/3}). -merge_msg_get_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_domain/3}). -merge_msg_domain(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S2#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S2#{uuid => PFuuid}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S3#{name => NFname}; - {#{name := PFname}, _} -> S3#{name => PFname}; - _ -> S3 - end, - S5 = case {PMsg, NMsg} of - {_, #{vcpu := NFvcpu}} -> S4#{vcpu => NFvcpu}; - {#{vcpu := PFvcpu}, _} -> S4#{vcpu => PFvcpu}; - _ -> S4 - end, - S6 = case {PMsg, NMsg} of - {_, #{memory := NFmemory}} -> S5#{memory => NFmemory}; - {#{memory := PFmemory}, _} -> S5#{memory => PFmemory}; - _ -> S5 - end, - S7 = case {PMsg, NMsg} of - {_, #{network := NFnetwork}} -> S6#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S6#{network => PFnetwork}; - _ -> S6 - end, - S8 = case {PMsg, NMsg} of - {_, #{bridge := NFbridge}} -> S7#{bridge => NFbridge}; - {#{bridge := PFbridge}, _} -> S7#{bridge => PFbridge}; - _ -> S7 - end, - S9 = case {PMsg, NMsg} of - {_, #{state := NFstate}} -> S8#{state => NFstate}; - {#{state := PFstate}, _} -> S8#{state => PFstate}; - _ -> S8 - end, - S10 = case {PMsg, NMsg} of - {_, #{private_ip := NFprivate_ip}} -> S9#{private_ip => NFprivate_ip}; - {#{private_ip := PFprivate_ip}, _} -> S9#{private_ip => PFprivate_ip}; - _ -> S9 - end, - S11 = case {PMsg, NMsg} of - {_, #{ipv6_address := NFipv6_address}} -> S10#{ipv6_address => NFipv6_address}; - {#{ipv6_address := PFipv6_address}, _} -> S10#{ipv6_address => PFipv6_address}; - _ -> S10 - end, - S12 = case {PMsg, NMsg} of - {_, #{user_data := NFuser_data}} -> S11#{user_data => NFuser_data}; - {#{user_data := PFuser_data}, _} -> S11#{user_data => PFuser_data}; - _ -> S11 - end, - S13 = case {PMsg, NMsg} of - {_, #{nested_virtualization := NFnested_virtualization}} -> S12#{nested_virtualization => NFnested_virtualization}; - {#{nested_virtualization := PFnested_virtualization}, _} -> S12#{nested_virtualization => PFnested_virtualization}; - _ -> S12 - end, - S14 = case {PMsg, NMsg} of - {_, #{base_image := NFbase_image}} -> S13#{base_image => NFbase_image}; - {#{base_image := PFbase_image}, _} -> S13#{base_image => PFbase_image}; - _ -> S13 - end, - S15 = case {PMsg, NMsg} of - {#{created_at := PFcreated_at}, #{created_at := NFcreated_at}} -> S14#{created_at => merge_msg_timestamp(PFcreated_at, NFcreated_at, TrUserData)}; - {_, #{created_at := NFcreated_at}} -> S14#{created_at => NFcreated_at}; - {#{created_at := PFcreated_at}, _} -> S14#{created_at => PFcreated_at}; - {_, _} -> S14 - end, - case {PMsg, NMsg} of - {_, #{os_type := NFos_type}} -> S15#{os_type => NFos_type}; - {#{os_type := PFos_type}, _} -> S15#{os_type => PFos_type}; - _ -> S15 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_request/3}). -merge_msg_list_domains_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_domains_response/3}). -merge_msg_list_domains_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{domains := PFdomains}, #{domains := NFdomains}} -> S1#{domains => 'erlang_++'(PFdomains, NFdomains, TrUserData)}; - {_, #{domains := NFdomains}} -> S1#{domains => NFdomains}; - {#{domains := PFdomains}, _} -> S1#{domains => PFdomains}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_domain_request/3}). -merge_msg_create_domain_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{domain := PFdomain}, #{domain := NFdomain}} -> S1#{domain => merge_msg_domain(PFdomain, NFdomain, TrUserData)}; - {_, #{domain := NFdomain}} -> S1#{domain => NFdomain}; - {#{domain := PFdomain}, _} -> S1#{domain => PFdomain}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_domain_request/3}). -merge_msg_delete_domain_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_download_image_request/3}). -merge_msg_download_image_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_image_chunk/3}). -merge_msg_image_chunk(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{bytes := NFbytes}} -> S1#{bytes => NFbytes}; - {#{bytes := PFbytes}, _} -> S1#{bytes => PFbytes}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_get_network_request/3}). -merge_msg_get_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_network/3}). -merge_msg_network(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{cidr := NFcidr}} -> S3#{cidr => NFcidr}; - {#{cidr := PFcidr}, _} -> S3#{cidr => PFcidr}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{cidr6 := NFcidr6}} -> S4#{cidr6 => NFcidr6}; - {#{cidr6 := PFcidr6}, _} -> S4#{cidr6 => PFcidr6}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_request/3}). -merge_msg_list_networks_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_networks_response/3}). -merge_msg_list_networks_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{networks := PFnetworks}, #{networks := NFnetworks}} -> S1#{networks => 'erlang_++'(PFnetworks, NFnetworks, TrUserData)}; - {_, #{networks := NFnetworks}} -> S1#{networks => NFnetworks}; - {#{networks := PFnetworks}, _} -> S1#{networks => PFnetworks}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_network_request/3}). -merge_msg_create_network_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{network := PFnetwork}, #{network := NFnetwork}} -> S1#{network => merge_msg_network(PFnetwork, NFnetwork, TrUserData)}; - {_, #{network := NFnetwork}} -> S1#{network => NFnetwork}; - {#{network := PFnetwork}, _} -> S1#{network => PFnetwork}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_network_request/3}). -merge_msg_delete_network_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_timestamp/3}). -merge_msg_timestamp(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{seconds := NFseconds}} -> S1#{seconds => NFseconds}; - {#{seconds := PFseconds}, _} -> S1#{seconds => PFseconds}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{nanos := NFnanos}} -> S2#{nanos => NFnanos}; - {#{nanos := PFnanos}, _} -> S2#{nanos => PFnanos}; - _ -> S2 - end. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - start_domain_request -> v_msg_start_domain_request(Msg, [MsgName], TrUserData); - stop_domain_request -> v_msg_stop_domain_request(Msg, [MsgName], TrUserData); - get_domain_request -> v_msg_get_domain_request(Msg, [MsgName], TrUserData); - domain -> v_msg_domain(Msg, [MsgName], TrUserData); - list_domains_request -> v_msg_list_domains_request(Msg, [MsgName], TrUserData); - list_domains_response -> v_msg_list_domains_response(Msg, [MsgName], TrUserData); - create_domain_request -> v_msg_create_domain_request(Msg, [MsgName], TrUserData); - delete_domain_request -> v_msg_delete_domain_request(Msg, [MsgName], TrUserData); - download_image_request -> v_msg_download_image_request(Msg, [MsgName], TrUserData); - image_chunk -> v_msg_image_chunk(Msg, [MsgName], TrUserData); - get_network_request -> v_msg_get_network_request(Msg, [MsgName], TrUserData); - network -> v_msg_network(Msg, [MsgName], TrUserData); - list_networks_request -> v_msg_list_networks_request(Msg, [MsgName], TrUserData); - list_networks_response -> v_msg_list_networks_response(Msg, [MsgName], TrUserData); - create_network_request -> v_msg_create_network_request(Msg, [MsgName], TrUserData); - delete_network_request -> v_msg_delete_network_request(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - timestamp -> v_msg_timestamp(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_start_domain_request/3}). --dialyzer({nowarn_function,v_msg_start_domain_request/3}). -v_msg_start_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_start_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), start_domain_request}, M, Path); -v_msg_start_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, start_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_stop_domain_request/3}). --dialyzer({nowarn_function,v_msg_stop_domain_request/3}). -v_msg_stop_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{force := F3} -> v_type_bool(F3, [force | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (uuid) -> ok; - (force) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_stop_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), stop_domain_request}, M, Path); -v_msg_stop_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, stop_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_get_domain_request/3}). --dialyzer({nowarn_function,v_msg_get_domain_request/3}). -v_msg_get_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_domain_request}, M, Path); -v_msg_get_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_domain/3}). --dialyzer({nowarn_function,v_msg_domain/3}). -v_msg_domain(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_uint64(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{uuid := F2} -> v_type_string(F2, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{vcpu := F4} -> v_type_uint32(F4, [vcpu | Path], TrUserData); - _ -> ok - end, - case M of - #{memory := F5} -> v_type_uint64(F5, [memory | Path], TrUserData); - _ -> ok - end, - case M of - #{network := F6} -> v_type_string(F6, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{bridge := F7} -> v_type_string(F7, [bridge | Path], TrUserData); - _ -> ok - end, - case M of - #{state := F8} -> v_type_string(F8, [state | Path], TrUserData); - _ -> ok - end, - case M of - #{private_ip := F9} -> v_type_string(F9, [private_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{ipv6_address := F10} -> v_type_string(F10, [ipv6_address | Path], TrUserData); - _ -> ok - end, - case M of - #{user_data := F11} -> v_type_string(F11, [user_data | Path], TrUserData); - _ -> ok - end, - case M of - #{nested_virtualization := F12} -> v_type_bool(F12, [nested_virtualization | Path], TrUserData); - _ -> ok - end, - case M of - #{base_image := F13} -> v_type_string(F13, [base_image | Path], TrUserData); - _ -> ok - end, - case M of - #{created_at := F14} -> v_msg_timestamp(F14, [created_at | Path], TrUserData); - _ -> ok - end, - case M of - #{os_type := F15} -> v_type_string(F15, [os_type | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (uuid) -> ok; - (name) -> ok; - (vcpu) -> ok; - (memory) -> ok; - (network) -> ok; - (bridge) -> ok; - (state) -> ok; - (private_ip) -> ok; - (ipv6_address) -> ok; - (user_data) -> ok; - (nested_virtualization) -> ok; - (base_image) -> ok; - (created_at) -> ok; - (os_type) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_domain(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), domain}, M, Path); -v_msg_domain(X, Path, _TrUserData) -> mk_type_error({expected_msg, domain}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_request/3}). --dialyzer({nowarn_function,v_msg_list_domains_request/3}). -v_msg_list_domains_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_request}, M, Path); -v_msg_list_domains_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_domains_response/3}). --dialyzer({nowarn_function,v_msg_list_domains_response/3}). -v_msg_list_domains_response(#{} = M, Path, TrUserData) -> - case M of - #{domains := F1} -> - if is_list(F1) -> - _ = [v_msg_domain(Elem, [domains | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, domain}}, F1, [domains | Path]) - end; - _ -> ok - end, - lists:foreach(fun (domains) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_domains_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_domains_response}, M, Path); -v_msg_list_domains_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_domains_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_domain_request/3}). --dialyzer({nowarn_function,v_msg_create_domain_request/3}). -v_msg_create_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{domain := F1} -> v_msg_domain(F1, [domain | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_domain_request}, M, Path); -v_msg_create_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_domain_request/3}). --dialyzer({nowarn_function,v_msg_delete_domain_request/3}). -v_msg_delete_domain_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_domain_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_domain_request}, M, Path); -v_msg_delete_domain_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_domain_request}, X, Path). - --compile({nowarn_unused_function,v_msg_download_image_request/3}). --dialyzer({nowarn_function,v_msg_download_image_request/3}). -v_msg_download_image_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_download_image_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), download_image_request}, M, Path); -v_msg_download_image_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, download_image_request}, X, Path). - --compile({nowarn_unused_function,v_msg_image_chunk/3}). --dialyzer({nowarn_function,v_msg_image_chunk/3}). -v_msg_image_chunk(#{} = M, Path, TrUserData) -> - case M of - #{bytes := F1} -> v_type_bytes(F1, [bytes | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (bytes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_image_chunk(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), image_chunk}, M, Path); -v_msg_image_chunk(X, Path, _TrUserData) -> mk_type_error({expected_msg, image_chunk}, X, Path). - --compile({nowarn_unused_function,v_msg_get_network_request/3}). --dialyzer({nowarn_function,v_msg_get_network_request/3}). -v_msg_get_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_network_request}, M, Path); -v_msg_get_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_network/3}). --dialyzer({nowarn_function,v_msg_network/3}). -v_msg_network(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr := F3} -> v_type_string(F3, [cidr | Path], TrUserData); - _ -> ok - end, - case M of - #{cidr6 := F4} -> v_type_string(F4, [cidr6 | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (name) -> ok; - (cidr) -> ok; - (cidr6) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_network(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), network}, M, Path); -v_msg_network(X, Path, _TrUserData) -> mk_type_error({expected_msg, network}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_request/3}). --dialyzer({nowarn_function,v_msg_list_networks_request/3}). -v_msg_list_networks_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_request}, M, Path); -v_msg_list_networks_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_networks_response/3}). --dialyzer({nowarn_function,v_msg_list_networks_response/3}). -v_msg_list_networks_response(#{} = M, Path, TrUserData) -> - case M of - #{networks := F1} -> - if is_list(F1) -> - _ = [v_msg_network(Elem, [networks | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, network}}, F1, [networks | Path]) - end; - _ -> ok - end, - lists:foreach(fun (networks) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_networks_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_networks_response}, M, Path); -v_msg_list_networks_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_networks_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_network_request/3}). --dialyzer({nowarn_function,v_msg_create_network_request/3}). -v_msg_create_network_request(#{} = M, Path, TrUserData) -> - case M of - #{network := F1} -> v_msg_network(F1, [network | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_network_request}, M, Path); -v_msg_create_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_network_request/3}). --dialyzer({nowarn_function,v_msg_delete_network_request/3}). -v_msg_delete_network_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_network_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_network_request}, M, Path); -v_msg_delete_network_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_network_request}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_msg_timestamp/3}). --dialyzer({nowarn_function,v_msg_timestamp/3}). -v_msg_timestamp(#{} = M, Path, TrUserData) -> - case M of - #{seconds := F1} -> v_type_int64(F1, [seconds | Path], TrUserData); - _ -> ok - end, - case M of - #{nanos := F2} -> v_type_int32(F2, [nanos | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (seconds) -> ok; - (nanos) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), timestamp}, M, Path); -v_msg_timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, timestamp}, X, Path). - --compile({nowarn_unused_function,v_type_int32/3}). --dialyzer({nowarn_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; -v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); -v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). - --compile({nowarn_unused_function,v_type_int64/3}). --dialyzer({nowarn_function,v_type_int64/3}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; -v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); -v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; -v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); -v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; -v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); -v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). - --compile({nowarn_unused_function,v_type_bool/3}). --dialyzer({nowarn_function,v_type_bool/3}). -v_type_bool(false, _Path, _TrUserData) -> ok; -v_type_bool(true, _Path, _TrUserData) -> ok; -v_type_bool(0, _Path, _TrUserData) -> ok; -v_type_bool(1, _Path, _TrUserData) -> ok; -v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,v_type_bytes/3}). --dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; -v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, start_domain_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, stop_domain_request}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]}, - {{msg, get_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, domain}, - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_domains_response}, [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]}, - {{msg, create_domain_request}, [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_domain_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, download_image_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, image_chunk}, [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]}, - {{msg, get_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, network}, - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_networks_response}, [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]}, - {{msg, create_network_request}, [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, delete_network_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, empty}, []}, - {{msg, timestamp}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}]. - - -get_msg_names() -> - [start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - empty, - timestamp]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [start_domain_request, - stop_domain_request, - get_domain_request, - domain, - list_domains_request, - list_domains_response, - create_domain_request, - delete_domain_request, - download_image_request, - image_chunk, - get_network_request, - network, - list_networks_request, - list_networks_response, - create_network_request, - delete_network_request, - empty, - timestamp]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(start_domain_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(stop_domain_request) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => force, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}]; -find_msg_def(get_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(domain) -> - [#{name => id, fnum => 1, rnum => 2, type => uint64, occurrence => optional, opts => []}, - #{name => uuid, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => vcpu, fnum => 4, rnum => 5, type => uint32, occurrence => optional, opts => []}, - #{name => memory, fnum => 5, rnum => 6, type => uint64, occurrence => optional, opts => []}, - #{name => network, fnum => 6, rnum => 7, type => string, occurrence => optional, opts => []}, - #{name => bridge, fnum => 7, rnum => 8, type => string, occurrence => optional, opts => []}, - #{name => state, fnum => 8, rnum => 9, type => string, occurrence => optional, opts => []}, - #{name => private_ip, fnum => 9, rnum => 10, type => string, occurrence => optional, opts => []}, - #{name => ipv6_address, fnum => 15, rnum => 11, type => string, occurrence => optional, opts => []}, - #{name => user_data, fnum => 10, rnum => 12, type => string, occurrence => optional, opts => []}, - #{name => nested_virtualization, fnum => 11, rnum => 13, type => bool, occurrence => optional, opts => []}, - #{name => base_image, fnum => 12, rnum => 14, type => string, occurrence => optional, opts => []}, - #{name => created_at, fnum => 13, rnum => 15, type => {msg, timestamp}, occurrence => optional, opts => []}, - #{name => os_type, fnum => 14, rnum => 16, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_domains_response) -> [#{name => domains, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => repeated, opts => []}]; -find_msg_def(create_domain_request) -> [#{name => domain, fnum => 1, rnum => 2, type => {msg, domain}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_domain_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(download_image_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(image_chunk) -> [#{name => bytes, fnum => 1, rnum => 2, type => bytes, occurrence => optional, opts => []}]; -find_msg_def(get_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(network) -> - [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => cidr, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => cidr6, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_networks_response) -> [#{name => networks, fnum => 1, rnum => 2, type => {msg, network}, occurrence => repeated, opts => []}]; -find_msg_def(create_network_request) -> [#{name => network, fnum => 1, rnum => 2, type => {msg, network}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(delete_network_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(empty) -> []; -find_msg_def(timestamp) -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => optional, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['DomainService']. - - -get_service_def('DomainService') -> - {{service, 'DomainService'}, - [#{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}, - #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('DomainService') -> ['GetDomain', 'ListDomains', 'CreateDomain', 'DeleteDomain', 'DownloadImage', 'GetNetwork', 'ListNetworks', 'CreateNetwork', 'DeleteNetwork']; -get_rpc_names(_) -> error. - - -find_rpc_def('DomainService', RpcName) -> find_rpc_def_DomainService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_DomainService('GetDomain') -> #{name => 'GetDomain', input => get_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListDomains') -> #{name => 'ListDomains', input => list_domains_request, output => list_domains_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateDomain') -> #{name => 'CreateDomain', input => create_domain_request, output => domain, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteDomain') -> #{name => 'DeleteDomain', input => delete_domain_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DownloadImage') -> #{name => 'DownloadImage', input => download_image_request, output => image_chunk, input_stream => false, output_stream => true, opts => []}; -find_rpc_def_DomainService('GetNetwork') -> #{name => 'GetNetwork', input => get_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('ListNetworks') -> #{name => 'ListNetworks', input => list_networks_request, output => list_networks_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('CreateNetwork') -> #{name => 'CreateNetwork', input => create_network_request, output => network, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService('DeleteNetwork') -> #{name => 'DeleteNetwork', input => delete_network_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_DomainService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"DomainService">>) -> 'DomainService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('DomainService') -> <<"DomainService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetDomain">>) -> {'DomainService', 'GetDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListDomains">>) -> {'DomainService', 'ListDomains'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateDomain">>) -> {'DomainService', 'CreateDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteDomain">>) -> {'DomainService', 'DeleteDomain'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DownloadImage">>) -> {'DomainService', 'DownloadImage'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"GetNetwork">>) -> {'DomainService', 'GetNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"ListNetworks">>) -> {'DomainService', 'ListNetworks'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"CreateNetwork">>) -> {'DomainService', 'CreateNetwork'}; -fqbins_to_service_and_rpc_name(<<"DomainService">>, <<"DeleteNetwork">>) -> {'DomainService', 'DeleteNetwork'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('DomainService', 'GetDomain') -> {<<"DomainService">>, <<"GetDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListDomains') -> {<<"DomainService">>, <<"ListDomains">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateDomain') -> {<<"DomainService">>, <<"CreateDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteDomain') -> {<<"DomainService">>, <<"DeleteDomain">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DownloadImage') -> {<<"DomainService">>, <<"DownloadImage">>}; -service_and_rpc_name_to_fqbins('DomainService', 'GetNetwork') -> {<<"DomainService">>, <<"GetNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'ListNetworks') -> {<<"DomainService">>, <<"ListNetworks">>}; -service_and_rpc_name_to_fqbins('DomainService', 'CreateNetwork') -> {<<"DomainService">>, <<"CreateNetwork">>}; -service_and_rpc_name_to_fqbins('DomainService', 'DeleteNetwork') -> {<<"DomainService">>, <<"DeleteNetwork">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"StartDomainRequest">>) -> start_domain_request; -fqbin_to_msg_name(<<"StopDomainRequest">>) -> stop_domain_request; -fqbin_to_msg_name(<<"GetDomainRequest">>) -> get_domain_request; -fqbin_to_msg_name(<<"Domain">>) -> domain; -fqbin_to_msg_name(<<"ListDomainsRequest">>) -> list_domains_request; -fqbin_to_msg_name(<<"ListDomainsResponse">>) -> list_domains_response; -fqbin_to_msg_name(<<"CreateDomainRequest">>) -> create_domain_request; -fqbin_to_msg_name(<<"DeleteDomainRequest">>) -> delete_domain_request; -fqbin_to_msg_name(<<"DownloadImageRequest">>) -> download_image_request; -fqbin_to_msg_name(<<"ImageChunk">>) -> image_chunk; -fqbin_to_msg_name(<<"GetNetworkRequest">>) -> get_network_request; -fqbin_to_msg_name(<<"Network">>) -> network; -fqbin_to_msg_name(<<"ListNetworksRequest">>) -> list_networks_request; -fqbin_to_msg_name(<<"ListNetworksResponse">>) -> list_networks_response; -fqbin_to_msg_name(<<"CreateNetworkRequest">>) -> create_network_request; -fqbin_to_msg_name(<<"DeleteNetworkRequest">>) -> delete_network_request; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(<<"google.protobuf.Timestamp">>) -> timestamp; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(start_domain_request) -> <<"StartDomainRequest">>; -msg_name_to_fqbin(stop_domain_request) -> <<"StopDomainRequest">>; -msg_name_to_fqbin(get_domain_request) -> <<"GetDomainRequest">>; -msg_name_to_fqbin(domain) -> <<"Domain">>; -msg_name_to_fqbin(list_domains_request) -> <<"ListDomainsRequest">>; -msg_name_to_fqbin(list_domains_response) -> <<"ListDomainsResponse">>; -msg_name_to_fqbin(create_domain_request) -> <<"CreateDomainRequest">>; -msg_name_to_fqbin(delete_domain_request) -> <<"DeleteDomainRequest">>; -msg_name_to_fqbin(download_image_request) -> <<"DownloadImageRequest">>; -msg_name_to_fqbin(image_chunk) -> <<"ImageChunk">>; -msg_name_to_fqbin(get_network_request) -> <<"GetNetworkRequest">>; -msg_name_to_fqbin(network) -> <<"Network">>; -msg_name_to_fqbin(list_networks_request) -> <<"ListNetworksRequest">>; -msg_name_to_fqbin(list_networks_response) -> <<"ListNetworksResponse">>; -msg_name_to_fqbin(create_network_request) -> <<"CreateNetworkRequest">>; -msg_name_to_fqbin(delete_network_request) -> <<"DeleteNetworkRequest">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(timestamp) -> <<"google.protobuf.Timestamp">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "domain.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["domain.proto", "empty.proto", "timestamp.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["domain", "empty", "timestamp"]. - - -get_msg_containment("domain") -> - [create_domain_request, - create_network_request, - delete_domain_request, - delete_network_request, - domain, - download_image_request, - get_domain_request, - get_network_request, - image_chunk, - list_domains_request, - list_domains_response, - list_networks_request, - list_networks_response, - network, - start_domain_request, - stop_domain_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment("timestamp") -> [timestamp]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("domain") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment("timestamp") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("domain") -> ['DomainService']; -get_service_containment("empty") -> []; -get_service_containment("timestamp") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("domain") -> - [{'DomainService', 'GetDomain'}, - {'DomainService', 'ListDomains'}, - {'DomainService', 'CreateDomain'}, - {'DomainService', 'DeleteDomain'}, - {'DomainService', 'DownloadImage'}, - {'DomainService', 'GetNetwork'}, - {'DomainService', 'ListNetworks'}, - {'DomainService', 'CreateNetwork'}, - {'DomainService', 'DeleteNetwork'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment("timestamp") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("domain") -> []; -get_enum_containment("empty") -> []; -get_enum_containment("timestamp") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Timestamp">>) -> "timestamp"; -get_proto_by_msg_name_as_fqbin(<<"StopDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"StartDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"GetDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DownloadImageRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"DeleteDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateNetworkRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"CreateDomainRequest">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListNetworksResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ListDomainsResponse">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(<<"Network">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"ImageChunk">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(<<"Domain">>) -> "domain"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"DomainService">>) -> "domain"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty", "timestamp"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/domain_service_bhvr.erl b/virtuerl/src/pb/domain_service_bhvr.erl deleted file mode 100644 index f01775b..0000000 --- a/virtuerl/src/pb/domain_service_bhvr.erl +++ /dev/null @@ -1,45 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service DomainService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(domain_service_bhvr). - -%% Unary RPC --callback get_domain(ctx:t(), domain_pb:get_domain_request()) -> - {ok, domain_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_domains(ctx:t(), domain_pb:list_domains_request()) -> - {ok, domain_pb:list_domains_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_domain(ctx:t(), domain_pb:create_domain_request()) -> - {ok, domain_pb:domain(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_domain(ctx:t(), domain_pb:delete_domain_request()) -> - {ok, domain_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% --callback download_image(domain_pb:download_image_request(), grpcbox_stream:t()) -> - ok | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_network(ctx:t(), domain_pb:get_network_request()) -> - {ok, domain_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_networks(ctx:t(), domain_pb:list_networks_request()) -> - {ok, domain_pb:list_networks_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_network(ctx:t(), domain_pb:create_network_request()) -> - {ok, domain_pb:network(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_network(ctx:t(), domain_pb:delete_network_request()) -> - {ok, domain_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/domain_service_client.erl b/virtuerl/src/pb/domain_service_client.erl deleted file mode 100644 index 9162a74..0000000 --- a/virtuerl/src/pb/domain_service_client.erl +++ /dev/null @@ -1,187 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service DomainService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(domain_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'DomainService'). --define(PROTO_MODULE, 'domain_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_domain(domain_pb:get_domain_request()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Input) -> - get_domain(ctx:new(), Input, #{}). - --spec get_domain(ctx:t() | domain_pb:get_domain_request(), domain_pb:get_domain_request() | grpcbox_client:options()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input) when ?is_ctx(Ctx) -> - get_domain(Ctx, Input, #{}); -get_domain(Input, Options) -> - get_domain(ctx:new(), Input, Options). - --spec get_domain(ctx:t(), domain_pb:get_domain_request(), grpcbox_client:options()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/GetDomain">>, Input, ?DEF(get_domain_request, domain, <<"GetDomainRequest">>), Options). - -%% @doc Unary RPC --spec list_domains(domain_pb:list_domains_request()) -> - {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Input) -> - list_domains(ctx:new(), Input, #{}). - --spec list_domains(ctx:t() | domain_pb:list_domains_request(), domain_pb:list_domains_request() | grpcbox_client:options()) -> - {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input) when ?is_ctx(Ctx) -> - list_domains(Ctx, Input, #{}); -list_domains(Input, Options) -> - list_domains(ctx:new(), Input, Options). - --spec list_domains(ctx:t(), domain_pb:list_domains_request(), grpcbox_client:options()) -> - {ok, domain_pb:list_domains_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_domains(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/ListDomains">>, Input, ?DEF(list_domains_request, list_domains_response, <<"ListDomainsRequest">>), Options). - -%% @doc Unary RPC --spec create_domain(domain_pb:create_domain_request()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Input) -> - create_domain(ctx:new(), Input, #{}). - --spec create_domain(ctx:t() | domain_pb:create_domain_request(), domain_pb:create_domain_request() | grpcbox_client:options()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input) when ?is_ctx(Ctx) -> - create_domain(Ctx, Input, #{}); -create_domain(Input, Options) -> - create_domain(ctx:new(), Input, Options). - --spec create_domain(ctx:t(), domain_pb:create_domain_request(), grpcbox_client:options()) -> - {ok, domain_pb:domain(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/CreateDomain">>, Input, ?DEF(create_domain_request, domain, <<"CreateDomainRequest">>), Options). - -%% @doc Unary RPC --spec delete_domain(domain_pb:delete_domain_request()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Input) -> - delete_domain(ctx:new(), Input, #{}). - --spec delete_domain(ctx:t() | domain_pb:delete_domain_request(), domain_pb:delete_domain_request() | grpcbox_client:options()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input) when ?is_ctx(Ctx) -> - delete_domain(Ctx, Input, #{}); -delete_domain(Input, Options) -> - delete_domain(ctx:new(), Input, Options). - --spec delete_domain(ctx:t(), domain_pb:delete_domain_request(), grpcbox_client:options()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_domain(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/DeleteDomain">>, Input, ?DEF(delete_domain_request, empty, <<"DeleteDomainRequest">>), Options). - -%% @doc --spec download_image(domain_pb:download_image_request()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Input) -> - download_image(ctx:new(), Input, #{}). - --spec download_image(ctx:t() | domain_pb:download_image_request(), domain_pb:download_image_request() | grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input) when ?is_ctx(Ctx) -> - download_image(Ctx, Input, #{}); -download_image(Input, Options) -> - download_image(ctx:new(), Input, Options). - --spec download_image(ctx:t(), domain_pb:download_image_request(), grpcbox_client:options()) -> - {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. -download_image(Ctx, Input, Options) -> - grpcbox_client:stream(Ctx, <<"/DomainService/DownloadImage">>, Input, ?DEF(download_image_request, image_chunk, <<"DownloadImageRequest">>), Options). - -%% @doc Unary RPC --spec get_network(domain_pb:get_network_request()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Input) -> - get_network(ctx:new(), Input, #{}). - --spec get_network(ctx:t() | domain_pb:get_network_request(), domain_pb:get_network_request() | grpcbox_client:options()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input) when ?is_ctx(Ctx) -> - get_network(Ctx, Input, #{}); -get_network(Input, Options) -> - get_network(ctx:new(), Input, Options). - --spec get_network(ctx:t(), domain_pb:get_network_request(), grpcbox_client:options()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/GetNetwork">>, Input, ?DEF(get_network_request, network, <<"GetNetworkRequest">>), Options). - -%% @doc Unary RPC --spec list_networks(domain_pb:list_networks_request()) -> - {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Input) -> - list_networks(ctx:new(), Input, #{}). - --spec list_networks(ctx:t() | domain_pb:list_networks_request(), domain_pb:list_networks_request() | grpcbox_client:options()) -> - {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input) when ?is_ctx(Ctx) -> - list_networks(Ctx, Input, #{}); -list_networks(Input, Options) -> - list_networks(ctx:new(), Input, Options). - --spec list_networks(ctx:t(), domain_pb:list_networks_request(), grpcbox_client:options()) -> - {ok, domain_pb:list_networks_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_networks(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/ListNetworks">>, Input, ?DEF(list_networks_request, list_networks_response, <<"ListNetworksRequest">>), Options). - -%% @doc Unary RPC --spec create_network(domain_pb:create_network_request()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Input) -> - create_network(ctx:new(), Input, #{}). - --spec create_network(ctx:t() | domain_pb:create_network_request(), domain_pb:create_network_request() | grpcbox_client:options()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input) when ?is_ctx(Ctx) -> - create_network(Ctx, Input, #{}); -create_network(Input, Options) -> - create_network(ctx:new(), Input, Options). - --spec create_network(ctx:t(), domain_pb:create_network_request(), grpcbox_client:options()) -> - {ok, domain_pb:network(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/CreateNetwork">>, Input, ?DEF(create_network_request, network, <<"CreateNetworkRequest">>), Options). - -%% @doc Unary RPC --spec delete_network(domain_pb:delete_network_request()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Input) -> - delete_network(ctx:new(), Input, #{}). - --spec delete_network(ctx:t() | domain_pb:delete_network_request(), domain_pb:delete_network_request() | grpcbox_client:options()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input) when ?is_ctx(Ctx) -> - delete_network(Ctx, Input, #{}); -delete_network(Input, Options) -> - delete_network(ctx:new(), Input, Options). - --spec delete_network(ctx:t(), domain_pb:delete_network_request(), grpcbox_client:options()) -> - {ok, domain_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_network(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/DomainService/DeleteNetwork">>, Input, ?DEF(delete_network_request, empty, <<"DeleteNetworkRequest">>), Options). - diff --git a/virtuerl/src/pb/host_pb.erl b/virtuerl/src/pb/host_pb.erl deleted file mode 100644 index 994eb97..0000000 --- a/virtuerl/src/pb/host_pb.erl +++ /dev/null @@ -1,1431 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(host_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type create_bootstrap_token_request() :: - #{expires_at => unicode:chardata() % = 1, optional - }. - --type create_bootstrap_token_response() :: - #{token => unicode:chardata() % = 1, optional - }. - --type host() :: - #{name => unicode:chardata(), % = 1, optional - address => unicode:chardata() % = 2, optional - }. - --type list_hosts_request() :: - #{ - }. - --type list_hosts_response() :: - #{hosts => [host()] % = 1, repeated - }. - --type register_host_request() :: - #{host => host(), % = 1, optional - token => unicode:chardata() % = 2, optional - }. - --type heartbeat_request() :: - #{host => host() % = 1, optional - }. - --type heartbeat_response() :: - #{ - }. - --type empty() :: - #{ - }. - --export_type(['create_bootstrap_token_request'/0, 'create_bootstrap_token_response'/0, 'host'/0, 'list_hosts_request'/0, 'list_hosts_response'/0, 'register_host_request'/0, 'heartbeat_request'/0, 'heartbeat_response'/0, 'empty'/0]). --type '$msg_name'() :: create_bootstrap_token_request | create_bootstrap_token_response | host | list_hosts_request | list_hosts_response | register_host_request | heartbeat_request | heartbeat_response | empty. --type '$msg'() :: create_bootstrap_token_request() | create_bootstrap_token_response() | host() | list_hosts_request() | list_hosts_response() | register_host_request() | heartbeat_request() | heartbeat_response() | empty(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - create_bootstrap_token_request -> encode_msg_create_bootstrap_token_request(id(Msg, TrUserData), TrUserData); - create_bootstrap_token_response -> encode_msg_create_bootstrap_token_response(id(Msg, TrUserData), TrUserData); - host -> encode_msg_host(id(Msg, TrUserData), TrUserData); - list_hosts_request -> encode_msg_list_hosts_request(id(Msg, TrUserData), TrUserData); - list_hosts_response -> encode_msg_list_hosts_response(id(Msg, TrUserData), TrUserData); - register_host_request -> encode_msg_register_host_request(id(Msg, TrUserData), TrUserData); - heartbeat_request -> encode_msg_heartbeat_request(id(Msg, TrUserData), TrUserData); - heartbeat_response -> encode_msg_heartbeat_response(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_create_bootstrap_token_request(Msg, TrUserData) -> encode_msg_create_bootstrap_token_request(Msg, <<>>, TrUserData). - - -encode_msg_create_bootstrap_token_request(#{} = M, Bin, TrUserData) -> - case M of - #{expires_at := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_create_bootstrap_token_response(Msg, TrUserData) -> encode_msg_create_bootstrap_token_response(Msg, <<>>, TrUserData). - - -encode_msg_create_bootstrap_token_response(#{} = M, Bin, TrUserData) -> - case M of - #{token := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_host(Msg, TrUserData) -> encode_msg_host(Msg, <<>>, TrUserData). - - -encode_msg_host(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{address := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_list_hosts_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_list_hosts_response(Msg, TrUserData) -> encode_msg_list_hosts_response(Msg, <<>>, TrUserData). - - -encode_msg_list_hosts_response(#{} = M, Bin, TrUserData) -> - case M of - #{hosts := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_hosts_response_hosts(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_register_host_request(Msg, TrUserData) -> encode_msg_register_host_request(Msg, <<>>, TrUserData). - - -encode_msg_register_host_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_register_host_request_host(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{token := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_heartbeat_request(Msg, TrUserData) -> encode_msg_heartbeat_request(Msg, <<>>, TrUserData). - - -encode_msg_heartbeat_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_heartbeat_request_host(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_heartbeat_response(_Msg, _TrUserData) -> <<>>. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -e_mfield_list_hosts_response_hosts(Msg, Bin, TrUserData) -> - SubBin = encode_msg_host(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_hosts_response_hosts([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_hosts_response_hosts(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_hosts_response_hosts(Rest, Bin3, TrUserData); -e_field_list_hosts_response_hosts([], Bin, _TrUserData) -> Bin. - -e_mfield_register_host_request_host(Msg, Bin, TrUserData) -> - SubBin = encode_msg_host(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_heartbeat_request_host(Msg, Bin, TrUserData) -> - SubBin = encode_msg_host(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(create_bootstrap_token_request, Bin, TrUserData) -> id(decode_msg_create_bootstrap_token_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_bootstrap_token_response, Bin, TrUserData) -> id(decode_msg_create_bootstrap_token_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(host, Bin, TrUserData) -> id(decode_msg_host(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_hosts_request, Bin, TrUserData) -> id(decode_msg_list_hosts_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_hosts_response, Bin, TrUserData) -> id(decode_msg_list_hosts_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(register_host_request, Bin, TrUserData) -> id(decode_msg_register_host_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(heartbeat_request, Bin, TrUserData) -> id(decode_msg_heartbeat_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(heartbeat_response, Bin, TrUserData) -> id(decode_msg_heartbeat_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). - - - -decode_msg_create_bootstrap_token_request(Bin, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_bootstrap_token_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_bootstrap_token_request_expires_at(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_create_bootstrap_token_request(<<>>, 0, 0, _, F@_1, _) -> #{expires_at => F@_1}; -dfp_read_field_def_create_bootstrap_token_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_bootstrap_token_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_create_bootstrap_token_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_bootstrap_token_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_create_bootstrap_token_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_bootstrap_token_request_expires_at(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_create_bootstrap_token_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_create_bootstrap_token_request(<<>>, 0, 0, _, F@_1, _) -> #{expires_at => F@_1}. - -d_field_create_bootstrap_token_request_expires_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_bootstrap_token_request_expires_at(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_create_bootstrap_token_request_expires_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_bootstrap_token_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_create_bootstrap_token_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_create_bootstrap_token_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_create_bootstrap_token_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_bootstrap_token_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_create_bootstrap_token_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_bootstrap_token_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_create_bootstrap_token_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_bootstrap_token_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_create_bootstrap_token_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_create_bootstrap_token_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_bootstrap_token_response(Bin, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_bootstrap_token_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_bootstrap_token_response_token(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_create_bootstrap_token_response(<<>>, 0, 0, _, F@_1, _) -> #{token => F@_1}; -dfp_read_field_def_create_bootstrap_token_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_bootstrap_token_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_create_bootstrap_token_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_bootstrap_token_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_create_bootstrap_token_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_bootstrap_token_response_token(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_create_bootstrap_token_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_create_bootstrap_token_response(<<>>, 0, 0, _, F@_1, _) -> #{token => F@_1}. - -d_field_create_bootstrap_token_response_token(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_bootstrap_token_response_token(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_create_bootstrap_token_response_token(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_bootstrap_token_response(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_create_bootstrap_token_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_create_bootstrap_token_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_create_bootstrap_token_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_bootstrap_token_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_create_bootstrap_token_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_bootstrap_token_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_create_bootstrap_token_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_bootstrap_token_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_create_bootstrap_token_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_create_bootstrap_token_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_bootstrap_token_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_host(Bin, TrUserData) -> dfp_read_field_def_host(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_host(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_host_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_host(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_host_address(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_host(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, address => F@_2}; -dfp_read_field_def_host(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_host(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_host(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_host_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_host_address(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_host(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_host(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{name => F@_1, address => F@_2}. - -d_field_host_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_host_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_host_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_host(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_host_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_host_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_host_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_host(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_host(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_host(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_host(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_host(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_host(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_host(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_host(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_list_hosts_request(Bin, TrUserData) -> dfp_read_field_def_list_hosts_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_list_hosts_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_list_hosts_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_list_hosts_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_list_hosts_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_hosts_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_list_hosts_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_list_hosts_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_list_hosts_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_list_hosts_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_list_hosts_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_list_hosts_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_list_hosts_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_list_hosts_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_list_hosts_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_hosts_request(Rest2, 0, 0, F, TrUserData). - -skip_group_list_hosts_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_hosts_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_list_hosts_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_list_hosts_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_list_hosts_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_list_hosts_response(Bin, TrUserData) -> dfp_read_field_def_list_hosts_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_hosts_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_hosts_response_hosts(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_hosts_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{hosts => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_hosts_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_hosts_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_hosts_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_hosts_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_hosts_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_hosts_response_hosts(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_hosts_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_hosts_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{hosts => lists_reverse(R1, TrUserData)} - end. - -d_field_list_hosts_response_hosts(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_hosts_response_hosts(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_hosts_response_hosts(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_hosts_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_hosts_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_hosts_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_hosts_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_hosts_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_hosts_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_hosts_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_hosts_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_hosts_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_hosts_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_hosts_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_hosts_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_register_host_request(Bin, TrUserData) -> dfp_read_field_def_register_host_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_register_host_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_register_host_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_register_host_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_register_host_request_token(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_register_host_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{token => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{host => F@_1} - end; -dfp_read_field_def_register_host_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_register_host_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_register_host_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_register_host_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_register_host_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_register_host_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_register_host_request_token(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_register_host_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_register_host_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{token => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{host => F@_1} - end. - -d_field_register_host_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_register_host_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_register_host_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_register_host_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_host(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_register_host_request_token(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_register_host_request_token(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_register_host_request_token(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_register_host_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_register_host_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_register_host_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_register_host_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_register_host_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_register_host_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_register_host_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_register_host_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_register_host_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_register_host_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_register_host_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_register_host_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_heartbeat_request(Bin, TrUserData) -> dfp_read_field_def_heartbeat_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_heartbeat_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_heartbeat_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_heartbeat_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{host => F@_1} - end; -dfp_read_field_def_heartbeat_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_heartbeat_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_heartbeat_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_heartbeat_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_heartbeat_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_heartbeat_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_heartbeat_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_heartbeat_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{host => F@_1} - end. - -d_field_heartbeat_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_heartbeat_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_heartbeat_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_host(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_heartbeat_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_host(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_heartbeat_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_heartbeat_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_heartbeat_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_heartbeat_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_heartbeat_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_heartbeat_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_heartbeat_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_heartbeat_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_heartbeat_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_heartbeat_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_heartbeat_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_heartbeat_response(Bin, TrUserData) -> dfp_read_field_def_heartbeat_response(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_heartbeat_response(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_heartbeat_response(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_heartbeat_response(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_heartbeat_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_heartbeat_response(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_heartbeat_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_heartbeat_response(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_heartbeat_response(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_heartbeat_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_heartbeat_response(Rest, Z1, Z2, F, TrUserData); -skip_varint_heartbeat_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_heartbeat_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_heartbeat_response(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_heartbeat_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_heartbeat_response(Rest2, 0, 0, F, TrUserData). - -skip_group_heartbeat_response(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_heartbeat_response(Rest, 0, Z2, FNum, TrUserData). - -skip_32_heartbeat_response(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). - -skip_64_heartbeat_response(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_heartbeat_response(Rest, Z1, Z2, F, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - create_bootstrap_token_request -> merge_msg_create_bootstrap_token_request(Prev, New, TrUserData); - create_bootstrap_token_response -> merge_msg_create_bootstrap_token_response(Prev, New, TrUserData); - host -> merge_msg_host(Prev, New, TrUserData); - list_hosts_request -> merge_msg_list_hosts_request(Prev, New, TrUserData); - list_hosts_response -> merge_msg_list_hosts_response(Prev, New, TrUserData); - register_host_request -> merge_msg_register_host_request(Prev, New, TrUserData); - heartbeat_request -> merge_msg_heartbeat_request(Prev, New, TrUserData); - heartbeat_response -> merge_msg_heartbeat_response(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_create_bootstrap_token_request/3}). -merge_msg_create_bootstrap_token_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{expires_at := NFexpires_at}} -> S1#{expires_at => NFexpires_at}; - {#{expires_at := PFexpires_at}, _} -> S1#{expires_at => PFexpires_at}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_bootstrap_token_response/3}). -merge_msg_create_bootstrap_token_response(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{token := NFtoken}} -> S1#{token => NFtoken}; - {#{token := PFtoken}, _} -> S1#{token => PFtoken}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_host/3}). -merge_msg_host(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S1#{name => NFname}; - {#{name := PFname}, _} -> S1#{name => PFname}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{address := NFaddress}} -> S2#{address => NFaddress}; - {#{address := PFaddress}, _} -> S2#{address => PFaddress}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_list_hosts_request/3}). -merge_msg_list_hosts_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_list_hosts_response/3}). -merge_msg_list_hosts_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{hosts := PFhosts}, #{hosts := NFhosts}} -> S1#{hosts => 'erlang_++'(PFhosts, NFhosts, TrUserData)}; - {_, #{hosts := NFhosts}} -> S1#{hosts => NFhosts}; - {#{hosts := PFhosts}, _} -> S1#{hosts => PFhosts}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_register_host_request/3}). -merge_msg_register_host_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{host := PFhost}, #{host := NFhost}} -> S1#{host => merge_msg_host(PFhost, NFhost, TrUserData)}; - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{token := NFtoken}} -> S2#{token => NFtoken}; - {#{token := PFtoken}, _} -> S2#{token => PFtoken}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_heartbeat_request/3}). -merge_msg_heartbeat_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{host := PFhost}, #{host := NFhost}} -> S1#{host => merge_msg_host(PFhost, NFhost, TrUserData)}; - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_heartbeat_response/3}). -merge_msg_heartbeat_response(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - create_bootstrap_token_request -> v_msg_create_bootstrap_token_request(Msg, [MsgName], TrUserData); - create_bootstrap_token_response -> v_msg_create_bootstrap_token_response(Msg, [MsgName], TrUserData); - host -> v_msg_host(Msg, [MsgName], TrUserData); - list_hosts_request -> v_msg_list_hosts_request(Msg, [MsgName], TrUserData); - list_hosts_response -> v_msg_list_hosts_response(Msg, [MsgName], TrUserData); - register_host_request -> v_msg_register_host_request(Msg, [MsgName], TrUserData); - heartbeat_request -> v_msg_heartbeat_request(Msg, [MsgName], TrUserData); - heartbeat_response -> v_msg_heartbeat_response(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_create_bootstrap_token_request/3}). --dialyzer({nowarn_function,v_msg_create_bootstrap_token_request/3}). -v_msg_create_bootstrap_token_request(#{} = M, Path, TrUserData) -> - case M of - #{expires_at := F1} -> v_type_string(F1, [expires_at | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (expires_at) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_bootstrap_token_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_bootstrap_token_request}, M, Path); -v_msg_create_bootstrap_token_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_bootstrap_token_request}, X, Path). - --compile({nowarn_unused_function,v_msg_create_bootstrap_token_response/3}). --dialyzer({nowarn_function,v_msg_create_bootstrap_token_response/3}). -v_msg_create_bootstrap_token_response(#{} = M, Path, TrUserData) -> - case M of - #{token := F1} -> v_type_string(F1, [token | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (token) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_bootstrap_token_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_bootstrap_token_response}, M, Path); -v_msg_create_bootstrap_token_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_bootstrap_token_response}, X, Path). - --compile({nowarn_unused_function,v_msg_host/3}). --dialyzer({nowarn_function,v_msg_host/3}). -v_msg_host(#{} = M, Path, TrUserData) -> - case M of - #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{address := F2} -> v_type_string(F2, [address | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (name) -> ok; - (address) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_host(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), host}, M, Path); -v_msg_host(X, Path, _TrUserData) -> mk_type_error({expected_msg, host}, X, Path). - --compile({nowarn_unused_function,v_msg_list_hosts_request/3}). --dialyzer({nowarn_function,v_msg_list_hosts_request/3}). -v_msg_list_hosts_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_list_hosts_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_hosts_request}, M, Path); -v_msg_list_hosts_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_hosts_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_hosts_response/3}). --dialyzer({nowarn_function,v_msg_list_hosts_response/3}). -v_msg_list_hosts_response(#{} = M, Path, TrUserData) -> - case M of - #{hosts := F1} -> - if is_list(F1) -> - _ = [v_msg_host(Elem, [hosts | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, host}}, F1, [hosts | Path]) - end; - _ -> ok - end, - lists:foreach(fun (hosts) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_hosts_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_hosts_response}, M, Path); -v_msg_list_hosts_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_hosts_response}, X, Path). - --compile({nowarn_unused_function,v_msg_register_host_request/3}). --dialyzer({nowarn_function,v_msg_register_host_request/3}). -v_msg_register_host_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_msg_host(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{token := F2} -> v_type_string(F2, [token | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (token) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_register_host_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), register_host_request}, M, Path); -v_msg_register_host_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, register_host_request}, X, Path). - --compile({nowarn_unused_function,v_msg_heartbeat_request/3}). --dialyzer({nowarn_function,v_msg_heartbeat_request/3}). -v_msg_heartbeat_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_msg_host(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_heartbeat_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), heartbeat_request}, M, Path); -v_msg_heartbeat_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, heartbeat_request}, X, Path). - --compile({nowarn_unused_function,v_msg_heartbeat_response/3}). --dialyzer({nowarn_function,v_msg_heartbeat_response/3}). -v_msg_heartbeat_response(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_heartbeat_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), heartbeat_response}, M, Path); -v_msg_heartbeat_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, heartbeat_response}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, create_bootstrap_token_request}, [#{name => expires_at, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, create_bootstrap_token_response}, [#{name => token, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, host}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => address, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, list_hosts_request}, []}, - {{msg, list_hosts_response}, [#{name => hosts, fnum => 1, rnum => 2, type => {msg, host}, occurrence => repeated, opts => []}]}, - {{msg, register_host_request}, [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}, #{name => token, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, heartbeat_request}, [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}]}, - {{msg, heartbeat_response}, []}, - {{msg, empty}, []}]. - - -get_msg_names() -> [create_bootstrap_token_request, create_bootstrap_token_response, host, list_hosts_request, list_hosts_response, register_host_request, heartbeat_request, heartbeat_response, empty]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> [create_bootstrap_token_request, create_bootstrap_token_response, host, list_hosts_request, list_hosts_response, register_host_request, heartbeat_request, heartbeat_response, empty]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(create_bootstrap_token_request) -> [#{name => expires_at, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(create_bootstrap_token_response) -> [#{name => token, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(host) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => address, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_hosts_request) -> []; -find_msg_def(list_hosts_response) -> [#{name => hosts, fnum => 1, rnum => 2, type => {msg, host}, occurrence => repeated, opts => []}]; -find_msg_def(register_host_request) -> [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}, #{name => token, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(heartbeat_request) -> [#{name => host, fnum => 1, rnum => 2, type => {msg, host}, occurrence => optional, opts => []}]; -find_msg_def(heartbeat_response) -> []; -find_msg_def(empty) -> []; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['HostService']. - - -get_service_def('HostService') -> - {{service, 'HostService'}, - [#{name => 'CreateBootstrapToken', input => create_bootstrap_token_request, output => create_bootstrap_token_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetHost', input => host, output => host, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListHosts', input => list_hosts_request, output => list_hosts_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'Register', input => register_host_request, output => host, input_stream => false, output_stream => false, opts => []}, - #{name => 'Deregister', input => host, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'Heartbeat', input => heartbeat_request, output => heartbeat_response, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('HostService') -> ['CreateBootstrapToken', 'GetHost', 'ListHosts', 'Register', 'Deregister', 'Heartbeat']; -get_rpc_names(_) -> error. - - -find_rpc_def('HostService', RpcName) -> find_rpc_def_HostService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_HostService('CreateBootstrapToken') -> #{name => 'CreateBootstrapToken', input => create_bootstrap_token_request, output => create_bootstrap_token_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService('GetHost') -> #{name => 'GetHost', input => host, output => host, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService('ListHosts') -> #{name => 'ListHosts', input => list_hosts_request, output => list_hosts_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService('Register') -> #{name => 'Register', input => register_host_request, output => host, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService('Deregister') -> #{name => 'Deregister', input => host, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService('Heartbeat') -> #{name => 'Heartbeat', input => heartbeat_request, output => heartbeat_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_HostService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"HostService">>) -> 'HostService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('HostService') -> <<"HostService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"CreateBootstrapToken">>) -> {'HostService', 'CreateBootstrapToken'}; -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"GetHost">>) -> {'HostService', 'GetHost'}; -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"ListHosts">>) -> {'HostService', 'ListHosts'}; -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Register">>) -> {'HostService', 'Register'}; -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Deregister">>) -> {'HostService', 'Deregister'}; -fqbins_to_service_and_rpc_name(<<"HostService">>, <<"Heartbeat">>) -> {'HostService', 'Heartbeat'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('HostService', 'CreateBootstrapToken') -> {<<"HostService">>, <<"CreateBootstrapToken">>}; -service_and_rpc_name_to_fqbins('HostService', 'GetHost') -> {<<"HostService">>, <<"GetHost">>}; -service_and_rpc_name_to_fqbins('HostService', 'ListHosts') -> {<<"HostService">>, <<"ListHosts">>}; -service_and_rpc_name_to_fqbins('HostService', 'Register') -> {<<"HostService">>, <<"Register">>}; -service_and_rpc_name_to_fqbins('HostService', 'Deregister') -> {<<"HostService">>, <<"Deregister">>}; -service_and_rpc_name_to_fqbins('HostService', 'Heartbeat') -> {<<"HostService">>, <<"Heartbeat">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"CreateBootstrapTokenRequest">>) -> create_bootstrap_token_request; -fqbin_to_msg_name(<<"CreateBootstrapTokenResponse">>) -> create_bootstrap_token_response; -fqbin_to_msg_name(<<"Host">>) -> host; -fqbin_to_msg_name(<<"ListHostsRequest">>) -> list_hosts_request; -fqbin_to_msg_name(<<"ListHostsResponse">>) -> list_hosts_response; -fqbin_to_msg_name(<<"RegisterHostRequest">>) -> register_host_request; -fqbin_to_msg_name(<<"HeartbeatRequest">>) -> heartbeat_request; -fqbin_to_msg_name(<<"HeartbeatResponse">>) -> heartbeat_response; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(create_bootstrap_token_request) -> <<"CreateBootstrapTokenRequest">>; -msg_name_to_fqbin(create_bootstrap_token_response) -> <<"CreateBootstrapTokenResponse">>; -msg_name_to_fqbin(host) -> <<"Host">>; -msg_name_to_fqbin(list_hosts_request) -> <<"ListHostsRequest">>; -msg_name_to_fqbin(list_hosts_response) -> <<"ListHostsResponse">>; -msg_name_to_fqbin(register_host_request) -> <<"RegisterHostRequest">>; -msg_name_to_fqbin(heartbeat_request) -> <<"HeartbeatRequest">>; -msg_name_to_fqbin(heartbeat_response) -> <<"HeartbeatResponse">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "host.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["host.proto", "empty.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["host", "empty"]. - - -get_msg_containment("host") -> [create_bootstrap_token_request, create_bootstrap_token_response, heartbeat_request, heartbeat_response, host, list_hosts_request, list_hosts_response, register_host_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("host") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("host") -> ['HostService']; -get_service_containment("empty") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("host") -> [{'HostService', 'CreateBootstrapToken'}, {'HostService', 'GetHost'}, {'HostService', 'ListHosts'}, {'HostService', 'Register'}, {'HostService', 'Deregister'}, {'HostService', 'Heartbeat'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("host") -> []; -get_enum_containment("empty") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"RegisterHostRequest">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"ListHostsRequest">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"Host">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"HeartbeatRequest">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"CreateBootstrapTokenRequest">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"ListHostsResponse">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"HeartbeatResponse">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"CreateBootstrapTokenResponse">>) -> "host"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"HostService">>) -> "host"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/host_service_bhvr.erl b/virtuerl/src/pb/host_service_bhvr.erl deleted file mode 100644 index afefefd..0000000 --- a/virtuerl/src/pb/host_service_bhvr.erl +++ /dev/null @@ -1,33 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service HostService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(host_service_bhvr). - -%% Unary RPC --callback create_bootstrap_token(ctx:t(), host_pb:create_bootstrap_token_request()) -> - {ok, host_pb:create_bootstrap_token_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_host(ctx:t(), host_pb:host()) -> - {ok, host_pb:host(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_hosts(ctx:t(), host_pb:list_hosts_request()) -> - {ok, host_pb:list_hosts_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback register(ctx:t(), host_pb:register_host_request()) -> - {ok, host_pb:host(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback deregister(ctx:t(), host_pb:host()) -> - {ok, host_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback heartbeat(ctx:t(), host_pb:heartbeat_request()) -> - {ok, host_pb:heartbeat_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/host_service_client.erl b/virtuerl/src/pb/host_service_client.erl deleted file mode 100644 index 3ac13f9..0000000 --- a/virtuerl/src/pb/host_service_client.erl +++ /dev/null @@ -1,133 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service HostService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(host_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'HostService'). --define(PROTO_MODULE, 'host_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec create_bootstrap_token(host_pb:create_bootstrap_token_request()) -> - {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_bootstrap_token(Input) -> - create_bootstrap_token(ctx:new(), Input, #{}). - --spec create_bootstrap_token(ctx:t() | host_pb:create_bootstrap_token_request(), host_pb:create_bootstrap_token_request() | grpcbox_client:options()) -> - {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_bootstrap_token(Ctx, Input) when ?is_ctx(Ctx) -> - create_bootstrap_token(Ctx, Input, #{}); -create_bootstrap_token(Input, Options) -> - create_bootstrap_token(ctx:new(), Input, Options). - --spec create_bootstrap_token(ctx:t(), host_pb:create_bootstrap_token_request(), grpcbox_client:options()) -> - {ok, host_pb:create_bootstrap_token_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_bootstrap_token(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/CreateBootstrapToken">>, Input, ?DEF(create_bootstrap_token_request, create_bootstrap_token_response, <<"CreateBootstrapTokenRequest">>), Options). - -%% @doc Unary RPC --spec get_host(host_pb:host()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_host(Input) -> - get_host(ctx:new(), Input, #{}). - --spec get_host(ctx:t() | host_pb:host(), host_pb:host() | grpcbox_client:options()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_host(Ctx, Input) when ?is_ctx(Ctx) -> - get_host(Ctx, Input, #{}); -get_host(Input, Options) -> - get_host(ctx:new(), Input, Options). - --spec get_host(ctx:t(), host_pb:host(), grpcbox_client:options()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_host(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/GetHost">>, Input, ?DEF(host, host, <<"Host">>), Options). - -%% @doc Unary RPC --spec list_hosts(host_pb:list_hosts_request()) -> - {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_hosts(Input) -> - list_hosts(ctx:new(), Input, #{}). - --spec list_hosts(ctx:t() | host_pb:list_hosts_request(), host_pb:list_hosts_request() | grpcbox_client:options()) -> - {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_hosts(Ctx, Input) when ?is_ctx(Ctx) -> - list_hosts(Ctx, Input, #{}); -list_hosts(Input, Options) -> - list_hosts(ctx:new(), Input, Options). - --spec list_hosts(ctx:t(), host_pb:list_hosts_request(), grpcbox_client:options()) -> - {ok, host_pb:list_hosts_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_hosts(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/ListHosts">>, Input, ?DEF(list_hosts_request, list_hosts_response, <<"ListHostsRequest">>), Options). - -%% @doc Unary RPC --spec register(host_pb:register_host_request()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -register(Input) -> - register(ctx:new(), Input, #{}). - --spec register(ctx:t() | host_pb:register_host_request(), host_pb:register_host_request() | grpcbox_client:options()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -register(Ctx, Input) when ?is_ctx(Ctx) -> - register(Ctx, Input, #{}); -register(Input, Options) -> - register(ctx:new(), Input, Options). - --spec register(ctx:t(), host_pb:register_host_request(), grpcbox_client:options()) -> - {ok, host_pb:host(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -register(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/Register">>, Input, ?DEF(register_host_request, host, <<"RegisterHostRequest">>), Options). - -%% @doc Unary RPC --spec deregister(host_pb:host()) -> - {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -deregister(Input) -> - deregister(ctx:new(), Input, #{}). - --spec deregister(ctx:t() | host_pb:host(), host_pb:host() | grpcbox_client:options()) -> - {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -deregister(Ctx, Input) when ?is_ctx(Ctx) -> - deregister(Ctx, Input, #{}); -deregister(Input, Options) -> - deregister(ctx:new(), Input, Options). - --spec deregister(ctx:t(), host_pb:host(), grpcbox_client:options()) -> - {ok, host_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -deregister(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/Deregister">>, Input, ?DEF(host, empty, <<"Host">>), Options). - -%% @doc Unary RPC --spec heartbeat(host_pb:heartbeat_request()) -> - {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -heartbeat(Input) -> - heartbeat(ctx:new(), Input, #{}). - --spec heartbeat(ctx:t() | host_pb:heartbeat_request(), host_pb:heartbeat_request() | grpcbox_client:options()) -> - {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -heartbeat(Ctx, Input) when ?is_ctx(Ctx) -> - heartbeat(Ctx, Input, #{}); -heartbeat(Input, Options) -> - heartbeat(ctx:new(), Input, Options). - --spec heartbeat(ctx:t(), host_pb:heartbeat_request(), grpcbox_client:options()) -> - {ok, host_pb:heartbeat_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -heartbeat(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/HostService/Heartbeat">>, Input, ?DEF(heartbeat_request, heartbeat_response, <<"HeartbeatRequest">>), Options). - diff --git a/virtuerl/src/pb/port_forwarding_pb.erl b/virtuerl/src/pb/port_forwarding_pb.erl deleted file mode 100644 index f36a103..0000000 --- a/virtuerl/src/pb/port_forwarding_pb.erl +++ /dev/null @@ -1,1320 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(port_forwarding_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type port_forwarding_identifier() :: - #{host => unicode:chardata(), % = 1, optional - protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer() % = 3, optional, 32 bits - }. - --type port_forwarding() :: - #{protocol => unicode:chardata(), % = 2, optional - source_port => non_neg_integer(), % = 3, optional, 32 bits - target_ip => unicode:chardata(), % = 4, optional - target_port => non_neg_integer() % = 5, optional, 32 bits - }. - --type list_port_forwardings_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_port_forwardings_response() :: - #{port_forwardings => [port_forwarding()] % = 1, repeated - }. - --type put_port_forwarding_request() :: - #{port_forwarding => port_forwarding(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type empty() :: - #{ - }. - --export_type(['port_forwarding_identifier'/0, 'port_forwarding'/0, 'list_port_forwardings_request'/0, 'list_port_forwardings_response'/0, 'put_port_forwarding_request'/0, 'empty'/0]). --type '$msg_name'() :: port_forwarding_identifier | port_forwarding | list_port_forwardings_request | list_port_forwardings_response | put_port_forwarding_request | empty. --type '$msg'() :: port_forwarding_identifier() | port_forwarding() | list_port_forwardings_request() | list_port_forwardings_response() | put_port_forwarding_request() | empty(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - port_forwarding_identifier -> encode_msg_port_forwarding_identifier(id(Msg, TrUserData), TrUserData); - port_forwarding -> encode_msg_port_forwarding(id(Msg, TrUserData), TrUserData); - list_port_forwardings_request -> encode_msg_list_port_forwardings_request(id(Msg, TrUserData), TrUserData); - list_port_forwardings_response -> encode_msg_list_port_forwardings_response(id(Msg, TrUserData), TrUserData); - put_port_forwarding_request -> encode_msg_put_port_forwarding_request(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_port_forwarding_identifier(Msg, TrUserData) -> encode_msg_port_forwarding_identifier(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{protocol := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{source_port := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_port_forwarding(Msg, TrUserData) -> encode_msg_port_forwarding(Msg, <<>>, TrUserData). - - -encode_msg_port_forwarding(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{protocol := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{source_port := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - B3 = case M of - #{target_ip := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end, - case M of - #{target_port := F4} -> - begin - TrF4 = id(F4, TrUserData), - if TrF4 =:= 0 -> B3; - true -> e_varint(TrF4, <>, TrUserData) - end - end; - _ -> B3 - end. - -encode_msg_list_port_forwardings_request(Msg, TrUserData) -> encode_msg_list_port_forwardings_request(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_port_forwardings_response(Msg, TrUserData) -> encode_msg_list_port_forwardings_response(Msg, <<>>, TrUserData). - - -encode_msg_list_port_forwardings_response(#{} = M, Bin, TrUserData) -> - case M of - #{port_forwardings := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_port_forwardings_response_port_forwardings(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_port_forwarding_request(Msg, TrUserData) -> encode_msg_put_port_forwarding_request(Msg, <<>>, TrUserData). - - -encode_msg_put_port_forwarding_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{port_forwarding := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_port_forwarding_request_port_forwarding(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -e_mfield_list_port_forwardings_response_port_forwardings(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_port_forwardings_response_port_forwardings([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_port_forwardings_response_port_forwardings(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_port_forwardings_response_port_forwardings(Rest, Bin3, TrUserData); -e_field_list_port_forwardings_response_port_forwardings([], Bin, _TrUserData) -> Bin. - -e_mfield_put_port_forwarding_request_port_forwarding(Msg, Bin, TrUserData) -> - SubBin = encode_msg_port_forwarding(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(port_forwarding_identifier, Bin, TrUserData) -> id(decode_msg_port_forwarding_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(port_forwarding, Bin, TrUserData) -> id(decode_msg_port_forwarding(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_request, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_port_forwardings_response, Bin, TrUserData) -> id(decode_msg_list_port_forwardings_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_port_forwarding_request, Bin, TrUserData) -> id(decode_msg_put_port_forwarding_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). - - - -decode_msg_port_forwarding_identifier(Bin, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_port_forwarding_identifier_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}; -dfp_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_port_forwarding_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_port_forwarding_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_port_forwarding_identifier_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_port_forwarding_identifier_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_port_forwarding_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_port_forwarding_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{host => F@_1, protocol => F@_2, source_port => F@_3}. - -d_field_port_forwarding_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_port_forwarding_identifier_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_port_forwarding_identifier_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_port_forwarding_identifier_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_port_forwarding_identifier_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_port_forwarding_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_port_forwarding_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_port_forwarding_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_port_forwarding_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_port_forwarding_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_port_forwarding_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_port_forwarding_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_port_forwarding_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_port_forwarding(Bin, TrUserData) -> dfp_read_field_def_port_forwarding(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_port_forwarding(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_protocol(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_source_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_ip(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<40, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_port_forwarding_target_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dfp_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}; -dfp_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_port_forwarding(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -dg_read_field_def_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -dg_read_field_def_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 18 -> d_field_port_forwarding_protocol(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 24 -> d_field_port_forwarding_source_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 34 -> d_field_port_forwarding_target_ip(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - 40 -> d_field_port_forwarding_target_port(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 1 -> skip_64_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 2 -> skip_length_delimited_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 3 -> skip_group_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData); - 5 -> skip_32_port_forwarding(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData) - end - end; -dg_read_field_def_port_forwarding(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #{protocol => F@_1, source_port => F@_2, target_ip => F@_3, target_port => F@_4}. - -d_field_port_forwarding_protocol(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_protocol(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_protocol(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_source_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_source_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_source_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData). - -d_field_port_forwarding_target_ip(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_ip(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_ip(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData). - -d_field_port_forwarding_target_port(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_port_forwarding_target_port(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -d_field_port_forwarding_target_port(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_port_forwarding(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData). - -skip_varint_port_forwarding(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_varint_port_forwarding(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_length_delimited_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData); -skip_length_delimited_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_port_forwarding(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_group_port_forwarding(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_port_forwarding(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_32_port_forwarding(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -skip_64_port_forwarding(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData). - -decode_msg_list_port_forwardings_request(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_port_forwardings_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_port_forwardings_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_port_forwardings_response(Bin, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_port_forwardings_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_port_forwardings_response_port_forwardings(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_port_forwardings_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_port_forwardings_response_port_forwardings(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_port_forwardings_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_port_forwardings_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{port_forwardings => lists_reverse(R1, TrUserData)} - end. - -d_field_list_port_forwardings_response_port_forwardings(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_port_forwardings_response_port_forwardings(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_port_forwardings_response_port_forwardings(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_port_forwardings_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_port_forwardings_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_port_forwardings_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_port_forwardings_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_port_forwardings_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_port_forwardings_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_port_forwardings_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_port_forwardings_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_port_forwardings_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_port_forwardings_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_port_forwardings_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_port_forwardings_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_port_forwarding_request(Bin, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_put_port_forwarding_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_port_forwarding(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_put_port_forwarding_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end; -dfp_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_put_port_forwarding_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_port_forwarding_request_port_forwarding(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_put_port_forwarding_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_put_port_forwarding_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_put_port_forwarding_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{port_forwarding => F@_1} - end. - -d_field_put_port_forwarding_request_port_forwarding(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_port_forwarding(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_port_forwarding(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_port_forwarding(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_port_forwarding(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_put_port_forwarding_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_put_port_forwarding_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_put_port_forwarding_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_put_port_forwarding_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_put_port_forwarding_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_put_port_forwarding_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_put_port_forwarding_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_put_port_forwarding_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_put_port_forwarding_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_port_forwarding_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_put_port_forwarding_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_port_forwarding_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_put_port_forwarding_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_put_port_forwarding_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_put_port_forwarding_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - port_forwarding_identifier -> merge_msg_port_forwarding_identifier(Prev, New, TrUserData); - port_forwarding -> merge_msg_port_forwarding(Prev, New, TrUserData); - list_port_forwardings_request -> merge_msg_list_port_forwardings_request(Prev, New, TrUserData); - list_port_forwardings_response -> merge_msg_list_port_forwardings_response(Prev, New, TrUserData); - put_port_forwarding_request -> merge_msg_put_port_forwarding_request(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding_identifier/3}). -merge_msg_port_forwarding_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S2#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S2#{protocol => PFprotocol}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S3#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S3#{source_port => PFsource_port}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_port_forwarding/3}). -merge_msg_port_forwarding(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{protocol := NFprotocol}} -> S1#{protocol => NFprotocol}; - {#{protocol := PFprotocol}, _} -> S1#{protocol => PFprotocol}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{source_port := NFsource_port}} -> S2#{source_port => NFsource_port}; - {#{source_port := PFsource_port}, _} -> S2#{source_port => PFsource_port}; - _ -> S2 - end, - S4 = case {PMsg, NMsg} of - {_, #{target_ip := NFtarget_ip}} -> S3#{target_ip => NFtarget_ip}; - {#{target_ip := PFtarget_ip}, _} -> S3#{target_ip => PFtarget_ip}; - _ -> S3 - end, - case {PMsg, NMsg} of - {_, #{target_port := NFtarget_port}} -> S4#{target_port => NFtarget_port}; - {#{target_port := PFtarget_port}, _} -> S4#{target_port => PFtarget_port}; - _ -> S4 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_request/3}). -merge_msg_list_port_forwardings_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_port_forwardings_response/3}). -merge_msg_list_port_forwardings_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{port_forwardings := PFport_forwardings}, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => 'erlang_++'(PFport_forwardings, NFport_forwardings, TrUserData)}; - {_, #{port_forwardings := NFport_forwardings}} -> S1#{port_forwardings => NFport_forwardings}; - {#{port_forwardings := PFport_forwardings}, _} -> S1#{port_forwardings => PFport_forwardings}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_port_forwarding_request/3}). -merge_msg_put_port_forwarding_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{port_forwarding := PFport_forwarding}, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => merge_msg_port_forwarding(PFport_forwarding, NFport_forwarding, TrUserData)}; - {_, #{port_forwarding := NFport_forwarding}} -> S1#{port_forwarding => NFport_forwarding}; - {#{port_forwarding := PFport_forwarding}, _} -> S1#{port_forwarding => PFport_forwarding}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - port_forwarding_identifier -> v_msg_port_forwarding_identifier(Msg, [MsgName], TrUserData); - port_forwarding -> v_msg_port_forwarding(Msg, [MsgName], TrUserData); - list_port_forwardings_request -> v_msg_list_port_forwardings_request(Msg, [MsgName], TrUserData); - list_port_forwardings_response -> v_msg_list_port_forwardings_response(Msg, [MsgName], TrUserData); - put_port_forwarding_request -> v_msg_put_port_forwarding_request(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_port_forwarding_identifier/3}). --dialyzer({nowarn_function,v_msg_port_forwarding_identifier/3}). -v_msg_port_forwarding_identifier(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{protocol := F2} -> v_type_string(F2, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F3} -> v_type_uint32(F3, [source_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (protocol) -> ok; - (source_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding_identifier}, M, Path); -v_msg_port_forwarding_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_port_forwarding/3}). --dialyzer({nowarn_function,v_msg_port_forwarding/3}). -v_msg_port_forwarding(#{} = M, Path, TrUserData) -> - case M of - #{protocol := F1} -> v_type_string(F1, [protocol | Path], TrUserData); - _ -> ok - end, - case M of - #{source_port := F2} -> v_type_uint32(F2, [source_port | Path], TrUserData); - _ -> ok - end, - case M of - #{target_ip := F3} -> v_type_string(F3, [target_ip | Path], TrUserData); - _ -> ok - end, - case M of - #{target_port := F4} -> v_type_uint32(F4, [target_port | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (protocol) -> ok; - (source_port) -> ok; - (target_ip) -> ok; - (target_port) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_port_forwarding(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), port_forwarding}, M, Path); -v_msg_port_forwarding(X, Path, _TrUserData) -> mk_type_error({expected_msg, port_forwarding}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_request/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_request/3}). -v_msg_list_port_forwardings_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_request}, M, Path); -v_msg_list_port_forwardings_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_port_forwardings_response/3}). --dialyzer({nowarn_function,v_msg_list_port_forwardings_response/3}). -v_msg_list_port_forwardings_response(#{} = M, Path, TrUserData) -> - case M of - #{port_forwardings := F1} -> - if is_list(F1) -> - _ = [v_msg_port_forwarding(Elem, [port_forwardings | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, port_forwarding}}, F1, [port_forwardings | Path]) - end; - _ -> ok - end, - lists:foreach(fun (port_forwardings) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_port_forwardings_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_port_forwardings_response}, M, Path); -v_msg_list_port_forwardings_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_port_forwardings_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_port_forwarding_request/3}). --dialyzer({nowarn_function,v_msg_put_port_forwarding_request/3}). -v_msg_put_port_forwarding_request(#{} = M, Path, TrUserData) -> - case M of - #{port_forwarding := F1} -> v_msg_port_forwarding(F1, [port_forwarding | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (port_forwarding) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_port_forwarding_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_port_forwarding_request}, M, Path); -v_msg_put_port_forwarding_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_port_forwarding_request}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; -v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); -v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, port_forwarding_identifier}, - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]}, - {{msg, port_forwarding}, - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_port_forwardings_response}, [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]}, - {{msg, put_port_forwarding_request}, [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, empty}, []}]. - - -get_msg_names() -> [port_forwarding_identifier, port_forwarding, list_port_forwardings_request, list_port_forwardings_response, put_port_forwarding_request, empty]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> [port_forwarding_identifier, port_forwarding, list_port_forwardings_request, list_port_forwardings_response, put_port_forwarding_request, empty]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(port_forwarding_identifier) -> - [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => protocol, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 4, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(port_forwarding) -> - [#{name => protocol, fnum => 2, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => source_port, fnum => 3, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => target_ip, fnum => 4, rnum => 4, type => string, occurrence => optional, opts => []}, - #{name => target_port, fnum => 5, rnum => 5, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_port_forwardings_response) -> [#{name => port_forwardings, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => repeated, opts => []}]; -find_msg_def(put_port_forwarding_request) -> - [#{name => port_forwarding, fnum => 1, rnum => 2, type => {msg, port_forwarding}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(empty) -> []; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['PortForwardingService']. - - -get_service_def('PortForwardingService') -> - {{service, 'PortForwardingService'}, - [#{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('PortForwardingService') -> ['GetPortForwarding', 'ListPortForwardings', 'PutPortForwarding', 'DeletePortForwarding']; -get_rpc_names(_) -> error. - - -find_rpc_def('PortForwardingService', RpcName) -> find_rpc_def_PortForwardingService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_PortForwardingService('GetPortForwarding') -> #{name => 'GetPortForwarding', input => port_forwarding_identifier, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('ListPortForwardings') -> #{name => 'ListPortForwardings', input => list_port_forwardings_request, output => list_port_forwardings_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('PutPortForwarding') -> #{name => 'PutPortForwarding', input => put_port_forwarding_request, output => port_forwarding, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService('DeletePortForwarding') -> #{name => 'DeletePortForwarding', input => port_forwarding_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_PortForwardingService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"PortForwardingService">>) -> 'PortForwardingService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('PortForwardingService') -> <<"PortForwardingService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"GetPortForwarding">>) -> {'PortForwardingService', 'GetPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"ListPortForwardings">>) -> {'PortForwardingService', 'ListPortForwardings'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"PutPortForwarding">>) -> {'PortForwardingService', 'PutPortForwarding'}; -fqbins_to_service_and_rpc_name(<<"PortForwardingService">>, <<"DeletePortForwarding">>) -> {'PortForwardingService', 'DeletePortForwarding'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('PortForwardingService', 'GetPortForwarding') -> {<<"PortForwardingService">>, <<"GetPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'ListPortForwardings') -> {<<"PortForwardingService">>, <<"ListPortForwardings">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'PutPortForwarding') -> {<<"PortForwardingService">>, <<"PutPortForwarding">>}; -service_and_rpc_name_to_fqbins('PortForwardingService', 'DeletePortForwarding') -> {<<"PortForwardingService">>, <<"DeletePortForwarding">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"PortForwardingIdentifier">>) -> port_forwarding_identifier; -fqbin_to_msg_name(<<"PortForwarding">>) -> port_forwarding; -fqbin_to_msg_name(<<"ListPortForwardingsRequest">>) -> list_port_forwardings_request; -fqbin_to_msg_name(<<"ListPortForwardingsResponse">>) -> list_port_forwardings_response; -fqbin_to_msg_name(<<"PutPortForwardingRequest">>) -> put_port_forwarding_request; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(port_forwarding_identifier) -> <<"PortForwardingIdentifier">>; -msg_name_to_fqbin(port_forwarding) -> <<"PortForwarding">>; -msg_name_to_fqbin(list_port_forwardings_request) -> <<"ListPortForwardingsRequest">>; -msg_name_to_fqbin(list_port_forwardings_response) -> <<"ListPortForwardingsResponse">>; -msg_name_to_fqbin(put_port_forwarding_request) -> <<"PutPortForwardingRequest">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "port_forwarding.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["port_forwarding.proto", "empty.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["port_forwarding", "empty"]. - - -get_msg_containment("port_forwarding") -> [list_port_forwardings_request, list_port_forwardings_response, port_forwarding, port_forwarding_identifier, put_port_forwarding_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("port_forwarding") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("port_forwarding") -> ['PortForwardingService']; -get_service_containment("empty") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("port_forwarding") -> [{'PortForwardingService', 'GetPortForwarding'}, {'PortForwardingService', 'ListPortForwardings'}, {'PortForwardingService', 'PutPortForwarding'}, {'PortForwardingService', 'DeletePortForwarding'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("port_forwarding") -> []; -get_enum_containment("empty") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"PortForwardingIdentifier">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"PutPortForwardingRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsRequest">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"ListPortForwardingsResponse">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"PortForwarding">>) -> "port_forwarding"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"PortForwardingService">>) -> "port_forwarding"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/port_forwarding_service_bhvr.erl b/virtuerl/src/pb/port_forwarding_service_bhvr.erl deleted file mode 100644 index 21208cf..0000000 --- a/virtuerl/src/pb/port_forwarding_service_bhvr.erl +++ /dev/null @@ -1,25 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service PortForwardingService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(port_forwarding_service_bhvr). - -%% Unary RPC --callback get_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier()) -> - {ok, port_forwarding_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_port_forwardings(ctx:t(), port_forwarding_pb:list_port_forwardings_request()) -> - {ok, port_forwarding_pb:list_port_forwardings_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_port_forwarding(ctx:t(), port_forwarding_pb:put_port_forwarding_request()) -> - {ok, port_forwarding_pb:port_forwarding(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier()) -> - {ok, port_forwarding_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/port_forwarding_service_client.erl b/virtuerl/src/pb/port_forwarding_service_client.erl deleted file mode 100644 index 6043ffa..0000000 --- a/virtuerl/src/pb/port_forwarding_service_client.erl +++ /dev/null @@ -1,97 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service PortForwardingService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(port_forwarding_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'PortForwardingService'). --define(PROTO_MODULE, 'port_forwarding_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_port_forwarding(port_forwarding_pb:port_forwarding_identifier()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Input) -> - get_port_forwarding(ctx:new(), Input, #{}). - --spec get_port_forwarding(ctx:t() | port_forwarding_pb:port_forwarding_identifier(), port_forwarding_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - get_port_forwarding(Ctx, Input, #{}); -get_port_forwarding(Input, Options) -> - get_port_forwarding(ctx:new(), Input, Options). - --spec get_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/PortForwardingService/GetPortForwarding">>, Input, ?DEF(port_forwarding_identifier, port_forwarding, <<"PortForwardingIdentifier">>), Options). - -%% @doc Unary RPC --spec list_port_forwardings(port_forwarding_pb:list_port_forwardings_request()) -> - {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Input) -> - list_port_forwardings(ctx:new(), Input, #{}). - --spec list_port_forwardings(ctx:t() | port_forwarding_pb:list_port_forwardings_request(), port_forwarding_pb:list_port_forwardings_request() | grpcbox_client:options()) -> - {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input) when ?is_ctx(Ctx) -> - list_port_forwardings(Ctx, Input, #{}); -list_port_forwardings(Input, Options) -> - list_port_forwardings(ctx:new(), Input, Options). - --spec list_port_forwardings(ctx:t(), port_forwarding_pb:list_port_forwardings_request(), grpcbox_client:options()) -> - {ok, port_forwarding_pb:list_port_forwardings_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_port_forwardings(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/PortForwardingService/ListPortForwardings">>, Input, ?DEF(list_port_forwardings_request, list_port_forwardings_response, <<"ListPortForwardingsRequest">>), Options). - -%% @doc Unary RPC --spec put_port_forwarding(port_forwarding_pb:put_port_forwarding_request()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Input) -> - put_port_forwarding(ctx:new(), Input, #{}). - --spec put_port_forwarding(ctx:t() | port_forwarding_pb:put_port_forwarding_request(), port_forwarding_pb:put_port_forwarding_request() | grpcbox_client:options()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - put_port_forwarding(Ctx, Input, #{}); -put_port_forwarding(Input, Options) -> - put_port_forwarding(ctx:new(), Input, Options). - --spec put_port_forwarding(ctx:t(), port_forwarding_pb:put_port_forwarding_request(), grpcbox_client:options()) -> - {ok, port_forwarding_pb:port_forwarding(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/PortForwardingService/PutPortForwarding">>, Input, ?DEF(put_port_forwarding_request, port_forwarding, <<"PutPortForwardingRequest">>), Options). - -%% @doc Unary RPC --spec delete_port_forwarding(port_forwarding_pb:port_forwarding_identifier()) -> - {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Input) -> - delete_port_forwarding(ctx:new(), Input, #{}). - --spec delete_port_forwarding(ctx:t() | port_forwarding_pb:port_forwarding_identifier(), port_forwarding_pb:port_forwarding_identifier() | grpcbox_client:options()) -> - {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input) when ?is_ctx(Ctx) -> - delete_port_forwarding(Ctx, Input, #{}); -delete_port_forwarding(Input, Options) -> - delete_port_forwarding(ctx:new(), Input, Options). - --spec delete_port_forwarding(ctx:t(), port_forwarding_pb:port_forwarding_identifier(), grpcbox_client:options()) -> - {ok, port_forwarding_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_port_forwarding(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/PortForwardingService/DeletePortForwarding">>, Input, ?DEF(port_forwarding_identifier, empty, <<"PortForwardingIdentifier">>), Options). - diff --git a/virtuerl/src/pb/route_pb.erl b/virtuerl/src/pb/route_pb.erl deleted file mode 100644 index c2c47f4..0000000 --- a/virtuerl/src/pb/route_pb.erl +++ /dev/null @@ -1,1912 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(route_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type route_table() :: - #{network_name => unicode:chardata(), % = 1, optional - id => non_neg_integer(), % = 2, optional, 32 bits - name => unicode:chardata() % = 3, optional - }. - --type route_table_identifier() :: - #{id => non_neg_integer() % = 1, optional, 32 bits - }. - --type list_route_tables_request() :: - #{network_name => unicode:chardata() % = 1, optional - }. - --type list_route_tables_response() :: - #{route_tables => [route_table()] % = 1, repeated - }. - --type create_route_table_request() :: - #{route_table => route_table() % = 1, optional - }. - --type route_identifier() :: - #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits - destination => unicode:chardata() % = 2, optional - }. - --type route() :: - #{route_table_id => non_neg_integer(), % = 1, optional, 32 bits - destination => unicode:chardata(), % = 2, optional - gateways => [unicode:chardata()] % = 3, repeated - }. - --type list_routes_request() :: - #{route_table_id => non_neg_integer() % = 1, optional, 32 bits - }. - --type list_routes_response() :: - #{routes => [route()] % = 1, repeated - }. - --type put_route_request() :: - #{route => route() % = 1, optional - }. - --type sync_request() :: - #{ - }. - --type empty() :: - #{ - }. - --export_type(['route_table'/0, 'route_table_identifier'/0, 'list_route_tables_request'/0, 'list_route_tables_response'/0, 'create_route_table_request'/0, 'route_identifier'/0, 'route'/0, 'list_routes_request'/0, 'list_routes_response'/0, 'put_route_request'/0, 'sync_request'/0, 'empty'/0]). --type '$msg_name'() :: route_table | route_table_identifier | list_route_tables_request | list_route_tables_response | create_route_table_request | route_identifier | route | list_routes_request | list_routes_response | put_route_request | sync_request | empty. --type '$msg'() :: route_table() | route_table_identifier() | list_route_tables_request() | list_route_tables_response() | create_route_table_request() | route_identifier() | route() | list_routes_request() | list_routes_response() | put_route_request() | sync_request() | empty(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - route_table -> encode_msg_route_table(id(Msg, TrUserData), TrUserData); - route_table_identifier -> encode_msg_route_table_identifier(id(Msg, TrUserData), TrUserData); - list_route_tables_request -> encode_msg_list_route_tables_request(id(Msg, TrUserData), TrUserData); - list_route_tables_response -> encode_msg_list_route_tables_response(id(Msg, TrUserData), TrUserData); - create_route_table_request -> encode_msg_create_route_table_request(id(Msg, TrUserData), TrUserData); - route_identifier -> encode_msg_route_identifier(id(Msg, TrUserData), TrUserData); - route -> encode_msg_route(id(Msg, TrUserData), TrUserData); - list_routes_request -> encode_msg_list_routes_request(id(Msg, TrUserData), TrUserData); - list_routes_response -> encode_msg_list_routes_response(id(Msg, TrUserData), TrUserData); - put_route_request -> encode_msg_put_route_request(id(Msg, TrUserData), TrUserData); - sync_request -> encode_msg_sync_request(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_route_table(Msg, TrUserData) -> encode_msg_route_table(Msg, <<>>, TrUserData). - - -encode_msg_route_table(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{network_name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{id := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= 0 -> B1; - true -> e_varint(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{name := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_route_table_identifier(Msg, TrUserData) -> encode_msg_route_table_identifier(Msg, <<>>, TrUserData). - - -encode_msg_route_table_identifier(#{} = M, Bin, TrUserData) -> - case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_route_tables_request(Msg, TrUserData) -> encode_msg_list_route_tables_request(Msg, <<>>, TrUserData). - - -encode_msg_list_route_tables_request(#{} = M, Bin, TrUserData) -> - case M of - #{network_name := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_route_tables_response(Msg, TrUserData) -> encode_msg_list_route_tables_response(Msg, <<>>, TrUserData). - - -encode_msg_list_route_tables_response(#{} = M, Bin, TrUserData) -> - case M of - #{route_tables := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_route_tables_response_route_tables(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_route_table_request(Msg, TrUserData) -> encode_msg_create_route_table_request(Msg, <<>>, TrUserData). - - -encode_msg_create_route_table_request(#{} = M, Bin, TrUserData) -> - case M of - #{route_table := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_route_table_request_route_table(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_route_identifier(Msg, TrUserData) -> encode_msg_route_identifier(Msg, <<>>, TrUserData). - - -encode_msg_route_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{destination := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_route(Msg, TrUserData) -> encode_msg_route(Msg, <<>>, TrUserData). - - -encode_msg_route(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{destination := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{gateways := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> e_field_route_gateways(TrF3, B2, TrUserData) - end; - _ -> B2 - end. - -encode_msg_list_routes_request(Msg, TrUserData) -> encode_msg_list_routes_request(Msg, <<>>, TrUserData). - - -encode_msg_list_routes_request(#{} = M, Bin, TrUserData) -> - case M of - #{route_table_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= 0 -> Bin; - true -> e_varint(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_routes_response(Msg, TrUserData) -> encode_msg_list_routes_response(Msg, <<>>, TrUserData). - - -encode_msg_list_routes_response(#{} = M, Bin, TrUserData) -> - case M of - #{routes := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_routes_response_routes(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_put_route_request(Msg, TrUserData) -> encode_msg_put_route_request(Msg, <<>>, TrUserData). - - -encode_msg_put_route_request(#{} = M, Bin, TrUserData) -> - case M of - #{route := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_put_route_request_route(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_sync_request(_Msg, _TrUserData) -> <<>>. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -e_mfield_list_route_tables_response_route_tables(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_route_tables_response_route_tables([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_route_tables_response_route_tables(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_route_tables_response_route_tables(Rest, Bin3, TrUserData); -e_field_list_route_tables_response_route_tables([], Bin, _TrUserData) -> Bin. - -e_mfield_create_route_table_request_route_table(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route_table(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_route_gateways([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), - e_field_route_gateways(Rest, Bin3, TrUserData); -e_field_route_gateways([], Bin, _TrUserData) -> Bin. - -e_mfield_list_routes_response_routes(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_routes_response_routes([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_routes_response_routes(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_routes_response_routes(Rest, Bin3, TrUserData); -e_field_list_routes_response_routes([], Bin, _TrUserData) -> Bin. - -e_mfield_put_route_request_route(Msg, Bin, TrUserData) -> - SubBin = encode_msg_route(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(route_table, Bin, TrUserData) -> id(decode_msg_route_table(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route_table_identifier, Bin, TrUserData) -> id(decode_msg_route_table_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_route_tables_request, Bin, TrUserData) -> id(decode_msg_list_route_tables_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_route_tables_response, Bin, TrUserData) -> id(decode_msg_list_route_tables_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_route_table_request, Bin, TrUserData) -> id(decode_msg_create_route_table_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route_identifier, Bin, TrUserData) -> id(decode_msg_route_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(route, Bin, TrUserData) -> id(decode_msg_route(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_routes_request, Bin, TrUserData) -> id(decode_msg_list_routes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_routes_response, Bin, TrUserData) -> id(decode_msg_list_routes_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(put_route_request, Bin, TrUserData) -> id(decode_msg_put_route_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(sync_request, Bin, TrUserData) -> id(decode_msg_sync_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). - - - -decode_msg_route_table(Bin, TrUserData) -> dfp_read_field_def_route_table(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_route_table(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_network_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_table_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}; -dfp_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route_table(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_route_table_network_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 16 -> d_field_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_route_table_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_route_table(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_route_table(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{network_name => F@_1, id => F@_2, name => F@_3}. - -d_field_route_table_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_table(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_route_table_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_table_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_table_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_table(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_route_table(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_route_table(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_table(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_route_table(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_table(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_route_table(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_route_table(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route_table(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_route_table_identifier(Bin, TrUserData) -> dfp_read_field_def_route_table_identifier(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). - -dfp_read_field_def_route_table_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_route_table_identifier_id(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}; -dfp_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_route_table_identifier(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_table_identifier_id(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_route_table_identifier(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_route_table_identifier(<<>>, 0, 0, _, F@_1, _) -> #{id => F@_1}. - -d_field_route_table_identifier_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_route_table_identifier_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_route_table_identifier_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_table_identifier(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_route_table_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_route_table_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_route_table_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_route_table_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_route_table_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_table_identifier(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_route_table_identifier(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_table_identifier(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_route_table_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_route_table_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_route_table_identifier(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_route_tables_request(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_route_tables_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_request_network_name(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}; -dfp_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_route_tables_request_network_name(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_route_tables_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_route_tables_request(<<>>, 0, 0, _, F@_1, _) -> #{network_name => F@_1}. - -d_field_list_route_tables_request_network_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_request_network_name(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_route_tables_request_network_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_route_tables_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_route_tables_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_route_tables_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_route_tables_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_route_tables_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_route_tables_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_route_tables_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_route_tables_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_route_tables_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_route_tables_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_route_tables_response(Bin, TrUserData) -> dfp_read_field_def_list_route_tables_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_route_tables_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_route_tables_response_route_tables(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{route_tables => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_route_tables_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_route_tables_response_route_tables(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_route_tables_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_route_tables_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{route_tables => lists_reverse(R1, TrUserData)} - end. - -d_field_list_route_tables_response_route_tables(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_route_tables_response_route_tables(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_route_tables_response_route_tables(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_route_tables_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_route_tables_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_route_tables_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_route_tables_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_route_tables_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_route_tables_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_route_tables_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_route_tables_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_route_tables_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_route_tables_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_route_tables_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_route_tables_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_route_table_request(Bin, TrUserData) -> dfp_read_field_def_create_route_table_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_create_route_table_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_create_route_table_request_route_table(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route_table => F@_1} - end; -dfp_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_create_route_table_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_route_table_request_route_table(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_create_route_table_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_create_route_table_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route_table => F@_1} - end. - -d_field_create_route_table_request_route_table(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_create_route_table_request_route_table(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_create_route_table_request_route_table(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route_table(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_route_table_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_route_table(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_create_route_table_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_create_route_table_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_create_route_table_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_create_route_table_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_create_route_table_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_route_table_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_create_route_table_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_route_table_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_create_route_table_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_create_route_table_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_create_route_table_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_route_identifier(Bin, TrUserData) -> dfp_read_field_def_route_identifier(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_route_identifier(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_route_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_route_identifier_destination(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}; -dfp_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_route_identifier(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_identifier_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_route_identifier_destination(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_route_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_route_identifier(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{route_table_id => F@_1, destination => F@_2}. - -d_field_route_identifier_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_route_identifier_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route_identifier(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_route_identifier_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_identifier_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_route_identifier_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route_identifier(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_route_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_route_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_route_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_route_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_route_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route_identifier(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_route_identifier(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_route_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_route_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_identifier(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_route(Bin, TrUserData) -> dfp_read_field_def_route(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id([], TrUserData), TrUserData). - -dfp_read_field_def_route(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_route_table_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_destination(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_route_gateways(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}; -dfp_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_route(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_route(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_route_route_table_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_route_destination(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_route_gateways(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_route(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_route(<<>>, 0, 0, _, F@_1, F@_2, R1, TrUserData) -> #{route_table_id => F@_1, destination => F@_2, gateways => lists_reverse(R1, TrUserData)}. - -d_field_route_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_route(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_route_destination(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_destination(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_destination(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_route_gateways(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_route_gateways(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_route_gateways(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_route(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_route(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_route(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_route(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_route(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_route(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_route(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_route(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_route(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_route(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_routes_request(Bin, TrUserData) -> dfp_read_field_def_list_routes_request(Bin, 0, 0, 0, id(0, TrUserData), TrUserData). - -dfp_read_field_def_list_routes_request(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_request_route_table_id(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}; -dfp_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 8 -> d_field_list_routes_request_route_table_id(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_routes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_routes_request(<<>>, 0, 0, _, F@_1, _) -> #{route_table_id => F@_1}. - -d_field_list_routes_request_route_table_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_request_route_table_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_routes_request_route_table_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, - dfp_read_field_def_list_routes_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_routes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_routes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_routes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_routes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_routes_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_routes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_routes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_routes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_routes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_routes_response(Bin, TrUserData) -> dfp_read_field_def_list_routes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_routes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_routes_response_routes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{routes => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_routes_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_routes_response_routes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_routes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_routes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{routes => lists_reverse(R1, TrUserData)} - end. - -d_field_list_routes_response_routes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_routes_response_routes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_routes_response_routes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_routes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_routes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_routes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_routes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_routes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_routes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_routes_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_routes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_routes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_routes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_routes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_routes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_put_route_request(Bin, TrUserData) -> dfp_read_field_def_put_route_request(Bin, 0, 0, 0, id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_put_route_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_put_route_request_route(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route => F@_1} - end; -dfp_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_put_route_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_put_route_request_route(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_put_route_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_put_route_request(<<>>, 0, 0, _, F@_1, _) -> - S1 = #{}, - if F@_1 == '$undef' -> S1; - true -> S1#{route => F@_1} - end. - -d_field_put_route_request_route(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_put_route_request_route(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_put_route_request_route(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_route(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_put_route_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_route(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_put_route_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_put_route_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_put_route_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_put_route_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_put_route_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_put_route_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_put_route_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_put_route_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_put_route_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_put_route_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_put_route_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_sync_request(Bin, TrUserData) -> dfp_read_field_def_sync_request(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_sync_request(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_sync_request(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_sync_request(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_sync_request(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_sync_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_sync_request(Rest, Z1, Z2, F, TrUserData); -skip_varint_sync_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_sync_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_sync_request(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_sync_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_sync_request(Rest2, 0, 0, F, TrUserData). - -skip_group_sync_request(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_sync_request(Rest, 0, Z2, FNum, TrUserData). - -skip_32_sync_request(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -skip_64_sync_request(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_sync_request(Rest, Z1, Z2, F, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - route_table -> merge_msg_route_table(Prev, New, TrUserData); - route_table_identifier -> merge_msg_route_table_identifier(Prev, New, TrUserData); - list_route_tables_request -> merge_msg_list_route_tables_request(Prev, New, TrUserData); - list_route_tables_response -> merge_msg_list_route_tables_response(Prev, New, TrUserData); - create_route_table_request -> merge_msg_create_route_table_request(Prev, New, TrUserData); - route_identifier -> merge_msg_route_identifier(Prev, New, TrUserData); - route -> merge_msg_route(Prev, New, TrUserData); - list_routes_request -> merge_msg_list_routes_request(Prev, New, TrUserData); - list_routes_response -> merge_msg_list_routes_response(Prev, New, TrUserData); - put_route_request -> merge_msg_put_route_request(Prev, New, TrUserData); - sync_request -> merge_msg_sync_request(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_route_table/3}). -merge_msg_route_table(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; - {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S2#{id => NFid}; - {#{id := PFid}, _} -> S2#{id => PFid}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{name := NFname}} -> S3#{name => NFname}; - {#{name := PFname}, _} -> S3#{name => PFname}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_route_table_identifier/3}). -merge_msg_route_table_identifier(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_route_tables_request/3}). -merge_msg_list_route_tables_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{network_name := NFnetwork_name}} -> S1#{network_name => NFnetwork_name}; - {#{network_name := PFnetwork_name}, _} -> S1#{network_name => PFnetwork_name}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_route_tables_response/3}). -merge_msg_list_route_tables_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route_tables := PFroute_tables}, #{route_tables := NFroute_tables}} -> S1#{route_tables => 'erlang_++'(PFroute_tables, NFroute_tables, TrUserData)}; - {_, #{route_tables := NFroute_tables}} -> S1#{route_tables => NFroute_tables}; - {#{route_tables := PFroute_tables}, _} -> S1#{route_tables => PFroute_tables}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_route_table_request/3}). -merge_msg_create_route_table_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route_table := PFroute_table}, #{route_table := NFroute_table}} -> S1#{route_table => merge_msg_route_table(PFroute_table, NFroute_table, TrUserData)}; - {_, #{route_table := NFroute_table}} -> S1#{route_table => NFroute_table}; - {#{route_table := PFroute_table}, _} -> S1#{route_table => PFroute_table}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_route_identifier/3}). -merge_msg_route_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; - {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_route/3}). -merge_msg_route(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{destination := NFdestination}} -> S2#{destination => NFdestination}; - {#{destination := PFdestination}, _} -> S2#{destination => PFdestination}; - _ -> S2 - end, - case {PMsg, NMsg} of - {#{gateways := PFgateways}, #{gateways := NFgateways}} -> S3#{gateways => 'erlang_++'(PFgateways, NFgateways, TrUserData)}; - {_, #{gateways := NFgateways}} -> S3#{gateways => NFgateways}; - {#{gateways := PFgateways}, _} -> S3#{gateways => PFgateways}; - {_, _} -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_routes_request/3}). -merge_msg_list_routes_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{route_table_id := NFroute_table_id}} -> S1#{route_table_id => NFroute_table_id}; - {#{route_table_id := PFroute_table_id}, _} -> S1#{route_table_id => PFroute_table_id}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_routes_response/3}). -merge_msg_list_routes_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{routes := PFroutes}, #{routes := NFroutes}} -> S1#{routes => 'erlang_++'(PFroutes, NFroutes, TrUserData)}; - {_, #{routes := NFroutes}} -> S1#{routes => NFroutes}; - {#{routes := PFroutes}, _} -> S1#{routes => PFroutes}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_put_route_request/3}). -merge_msg_put_route_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{route := PFroute}, #{route := NFroute}} -> S1#{route => merge_msg_route(PFroute, NFroute, TrUserData)}; - {_, #{route := NFroute}} -> S1#{route => NFroute}; - {#{route := PFroute}, _} -> S1#{route => PFroute}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_sync_request/3}). -merge_msg_sync_request(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - route_table -> v_msg_route_table(Msg, [MsgName], TrUserData); - route_table_identifier -> v_msg_route_table_identifier(Msg, [MsgName], TrUserData); - list_route_tables_request -> v_msg_list_route_tables_request(Msg, [MsgName], TrUserData); - list_route_tables_response -> v_msg_list_route_tables_response(Msg, [MsgName], TrUserData); - create_route_table_request -> v_msg_create_route_table_request(Msg, [MsgName], TrUserData); - route_identifier -> v_msg_route_identifier(Msg, [MsgName], TrUserData); - route -> v_msg_route(Msg, [MsgName], TrUserData); - list_routes_request -> v_msg_list_routes_request(Msg, [MsgName], TrUserData); - list_routes_response -> v_msg_list_routes_response(Msg, [MsgName], TrUserData); - put_route_request -> v_msg_put_route_request(Msg, [MsgName], TrUserData); - sync_request -> v_msg_sync_request(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_route_table/3}). --dialyzer({nowarn_function,v_msg_route_table/3}). -v_msg_route_table(#{} = M, Path, TrUserData) -> - case M of - #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); - _ -> ok - end, - case M of - #{id := F2} -> v_type_uint32(F2, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F3} -> v_type_string(F3, [name | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network_name) -> ok; - (id) -> ok; - (name) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_table(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table}, M, Path); -v_msg_route_table(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table}, X, Path). - --compile({nowarn_unused_function,v_msg_route_table_identifier/3}). --dialyzer({nowarn_function,v_msg_route_table_identifier/3}). -v_msg_route_table_identifier(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_uint32(F1, [id | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_table_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_table_identifier}, M, Path); -v_msg_route_table_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_table_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_list_route_tables_request/3}). --dialyzer({nowarn_function,v_msg_list_route_tables_request/3}). -v_msg_list_route_tables_request(#{} = M, Path, TrUserData) -> - case M of - #{network_name := F1} -> v_type_string(F1, [network_name | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (network_name) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_route_tables_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_request}, M, Path); -v_msg_list_route_tables_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_route_tables_response/3}). --dialyzer({nowarn_function,v_msg_list_route_tables_response/3}). -v_msg_list_route_tables_response(#{} = M, Path, TrUserData) -> - case M of - #{route_tables := F1} -> - if is_list(F1) -> - _ = [v_msg_route_table(Elem, [route_tables | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, route_table}}, F1, [route_tables | Path]) - end; - _ -> ok - end, - lists:foreach(fun (route_tables) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_route_tables_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_route_tables_response}, M, Path); -v_msg_list_route_tables_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_route_tables_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_route_table_request/3}). --dialyzer({nowarn_function,v_msg_create_route_table_request/3}). -v_msg_create_route_table_request(#{} = M, Path, TrUserData) -> - case M of - #{route_table := F1} -> v_msg_route_table(F1, [route_table | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_route_table_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_route_table_request}, M, Path); -v_msg_create_route_table_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_route_table_request}, X, Path). - --compile({nowarn_unused_function,v_msg_route_identifier/3}). --dialyzer({nowarn_function,v_msg_route_identifier/3}). -v_msg_route_identifier(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - case M of - #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (destination) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_identifier}, M, Path); -v_msg_route_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_route/3}). --dialyzer({nowarn_function,v_msg_route/3}). -v_msg_route(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - case M of - #{destination := F2} -> v_type_string(F2, [destination | Path], TrUserData); - _ -> ok - end, - case M of - #{gateways := F3} -> - if is_list(F3) -> - _ = [v_type_string(Elem, [gateways | Path], TrUserData) || Elem <- F3], - ok; - true -> mk_type_error({invalid_list_of, string}, F3, [gateways | Path]) - end; - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (destination) -> ok; - (gateways) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_route(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route}, M, Path); -v_msg_route(X, Path, _TrUserData) -> mk_type_error({expected_msg, route}, X, Path). - --compile({nowarn_unused_function,v_msg_list_routes_request/3}). --dialyzer({nowarn_function,v_msg_list_routes_request/3}). -v_msg_list_routes_request(#{} = M, Path, TrUserData) -> - case M of - #{route_table_id := F1} -> v_type_uint32(F1, [route_table_id | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route_table_id) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_routes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_request}, M, Path); -v_msg_list_routes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_routes_response/3}). --dialyzer({nowarn_function,v_msg_list_routes_response/3}). -v_msg_list_routes_response(#{} = M, Path, TrUserData) -> - case M of - #{routes := F1} -> - if is_list(F1) -> - _ = [v_msg_route(Elem, [routes | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, route}}, F1, [routes | Path]) - end; - _ -> ok - end, - lists:foreach(fun (routes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_routes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_routes_response}, M, Path); -v_msg_list_routes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_routes_response}, X, Path). - --compile({nowarn_unused_function,v_msg_put_route_request/3}). --dialyzer({nowarn_function,v_msg_put_route_request/3}). -v_msg_put_route_request(#{} = M, Path, TrUserData) -> - case M of - #{route := F1} -> v_msg_route(F1, [route | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (route) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_put_route_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), put_route_request}, M, Path); -v_msg_put_route_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, put_route_request}, X, Path). - --compile({nowarn_unused_function,v_msg_sync_request/3}). --dialyzer({nowarn_function,v_msg_sync_request/3}). -v_msg_sync_request(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_sync_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), sync_request}, M, Path); -v_msg_sync_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, sync_request}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_type_uint32/3}). --dialyzer({nowarn_function,v_type_uint32/3}). -v_type_uint32(N, _Path, _TrUserData) when 0 =< N, N =< 4294967295 -> ok; -v_type_uint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint32, unsigned, 32}, N, Path); -v_type_uint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint32, unsigned, 32}, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, route_table}, - [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, route_table_identifier}, [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_route_tables_request}, [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_route_tables_response}, [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]}, - {{msg, create_route_table_request}, [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]}, - {{msg, route_identifier}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, route}, - [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, - #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]}, - {{msg, list_routes_request}, [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]}, - {{msg, list_routes_response}, [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]}, - {{msg, put_route_request}, [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]}, - {{msg, sync_request}, []}, - {{msg, empty}, []}]. - - -get_msg_names() -> [route_table, route_table_identifier, list_route_tables_request, list_route_tables_response, create_route_table_request, route_identifier, route, list_routes_request, list_routes_response, put_route_request, sync_request, empty]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [route_table, route_table_identifier, list_route_tables_request, list_route_tables_response, create_route_table_request, route_identifier, route, list_routes_request, list_routes_response, put_route_request, sync_request, empty]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(route_table) -> - [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => id, fnum => 2, rnum => 3, type => uint32, occurrence => optional, opts => []}, - #{name => name, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(route_table_identifier) -> [#{name => id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_route_tables_request) -> [#{name => network_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_route_tables_response) -> [#{name => route_tables, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => repeated, opts => []}]; -find_msg_def(create_route_table_request) -> [#{name => route_table, fnum => 1, rnum => 2, type => {msg, route_table}, occurrence => optional, opts => []}]; -find_msg_def(route_identifier) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(route) -> - [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}, - #{name => destination, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => gateways, fnum => 3, rnum => 4, type => string, occurrence => repeated, opts => []}]; -find_msg_def(list_routes_request) -> [#{name => route_table_id, fnum => 1, rnum => 2, type => uint32, occurrence => optional, opts => []}]; -find_msg_def(list_routes_response) -> [#{name => routes, fnum => 1, rnum => 2, type => {msg, route}, occurrence => repeated, opts => []}]; -find_msg_def(put_route_request) -> [#{name => route, fnum => 1, rnum => 2, type => {msg, route}, occurrence => optional, opts => []}]; -find_msg_def(sync_request) -> []; -find_msg_def(empty) -> []; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['RouteService']. - - -get_service_def('RouteService') -> - {{service, 'RouteService'}, - [#{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('RouteService') -> ['GetRouteTable', 'ListRouteTables', 'CreateRouteTable', 'DeleteRouteTable', 'GetRoute', 'ListRoutes', 'PutRoute', 'DeleteRoute', 'Sync']; -get_rpc_names(_) -> error. - - -find_rpc_def('RouteService', RpcName) -> find_rpc_def_RouteService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_RouteService('GetRouteTable') -> #{name => 'GetRouteTable', input => route_table_identifier, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('ListRouteTables') -> #{name => 'ListRouteTables', input => list_route_tables_request, output => list_route_tables_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('CreateRouteTable') -> #{name => 'CreateRouteTable', input => create_route_table_request, output => route_table, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('DeleteRouteTable') -> #{name => 'DeleteRouteTable', input => route_table_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('GetRoute') -> #{name => 'GetRoute', input => route_identifier, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('ListRoutes') -> #{name => 'ListRoutes', input => list_routes_request, output => list_routes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('PutRoute') -> #{name => 'PutRoute', input => put_route_request, output => route, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('DeleteRoute') -> #{name => 'DeleteRoute', input => route_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService('Sync') -> #{name => 'Sync', input => sync_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_RouteService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"RouteService">>) -> 'RouteService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('RouteService') -> <<"RouteService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRouteTable">>) -> {'RouteService', 'GetRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRouteTables">>) -> {'RouteService', 'ListRouteTables'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"CreateRouteTable">>) -> {'RouteService', 'CreateRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRouteTable">>) -> {'RouteService', 'DeleteRouteTable'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"GetRoute">>) -> {'RouteService', 'GetRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"ListRoutes">>) -> {'RouteService', 'ListRoutes'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"PutRoute">>) -> {'RouteService', 'PutRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"DeleteRoute">>) -> {'RouteService', 'DeleteRoute'}; -fqbins_to_service_and_rpc_name(<<"RouteService">>, <<"Sync">>) -> {'RouteService', 'Sync'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('RouteService', 'GetRouteTable') -> {<<"RouteService">>, <<"GetRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'ListRouteTables') -> {<<"RouteService">>, <<"ListRouteTables">>}; -service_and_rpc_name_to_fqbins('RouteService', 'CreateRouteTable') -> {<<"RouteService">>, <<"CreateRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'DeleteRouteTable') -> {<<"RouteService">>, <<"DeleteRouteTable">>}; -service_and_rpc_name_to_fqbins('RouteService', 'GetRoute') -> {<<"RouteService">>, <<"GetRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'ListRoutes') -> {<<"RouteService">>, <<"ListRoutes">>}; -service_and_rpc_name_to_fqbins('RouteService', 'PutRoute') -> {<<"RouteService">>, <<"PutRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'DeleteRoute') -> {<<"RouteService">>, <<"DeleteRoute">>}; -service_and_rpc_name_to_fqbins('RouteService', 'Sync') -> {<<"RouteService">>, <<"Sync">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"RouteTable">>) -> route_table; -fqbin_to_msg_name(<<"RouteTableIdentifier">>) -> route_table_identifier; -fqbin_to_msg_name(<<"ListRouteTablesRequest">>) -> list_route_tables_request; -fqbin_to_msg_name(<<"ListRouteTablesResponse">>) -> list_route_tables_response; -fqbin_to_msg_name(<<"CreateRouteTableRequest">>) -> create_route_table_request; -fqbin_to_msg_name(<<"RouteIdentifier">>) -> route_identifier; -fqbin_to_msg_name(<<"Route">>) -> route; -fqbin_to_msg_name(<<"ListRoutesRequest">>) -> list_routes_request; -fqbin_to_msg_name(<<"ListRoutesResponse">>) -> list_routes_response; -fqbin_to_msg_name(<<"PutRouteRequest">>) -> put_route_request; -fqbin_to_msg_name(<<"SyncRequest">>) -> sync_request; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(route_table) -> <<"RouteTable">>; -msg_name_to_fqbin(route_table_identifier) -> <<"RouteTableIdentifier">>; -msg_name_to_fqbin(list_route_tables_request) -> <<"ListRouteTablesRequest">>; -msg_name_to_fqbin(list_route_tables_response) -> <<"ListRouteTablesResponse">>; -msg_name_to_fqbin(create_route_table_request) -> <<"CreateRouteTableRequest">>; -msg_name_to_fqbin(route_identifier) -> <<"RouteIdentifier">>; -msg_name_to_fqbin(route) -> <<"Route">>; -msg_name_to_fqbin(list_routes_request) -> <<"ListRoutesRequest">>; -msg_name_to_fqbin(list_routes_response) -> <<"ListRoutesResponse">>; -msg_name_to_fqbin(put_route_request) -> <<"PutRouteRequest">>; -msg_name_to_fqbin(sync_request) -> <<"SyncRequest">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "route.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["route.proto", "empty.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["route", "empty"]. - - -get_msg_containment("route") -> - [create_route_table_request, list_route_tables_request, list_route_tables_response, list_routes_request, list_routes_response, put_route_request, route, route_identifier, route_table, route_table_identifier, sync_request]; -get_msg_containment("empty") -> [empty]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("route") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("route") -> ['RouteService']; -get_service_containment("empty") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("route") -> - [{'RouteService', 'GetRouteTable'}, - {'RouteService', 'ListRouteTables'}, - {'RouteService', 'CreateRouteTable'}, - {'RouteService', 'DeleteRouteTable'}, - {'RouteService', 'GetRoute'}, - {'RouteService', 'ListRoutes'}, - {'RouteService', 'PutRoute'}, - {'RouteService', 'DeleteRoute'}, - {'RouteService', 'Sync'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("route") -> []; -get_enum_containment("empty") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"RouteTableIdentifier">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"RouteIdentifier">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"SyncRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"PutRouteRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRoutesRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"CreateRouteTableRequest">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"RouteTable">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"Route">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRoutesResponse">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"ListRouteTablesResponse">>) -> "route"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"RouteService">>) -> "route"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/route_service_bhvr.erl b/virtuerl/src/pb/route_service_bhvr.erl deleted file mode 100644 index 35673a4..0000000 --- a/virtuerl/src/pb/route_service_bhvr.erl +++ /dev/null @@ -1,45 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service RouteService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(route_service_bhvr). - -%% Unary RPC --callback get_route_table(ctx:t(), route_pb:route_table_identifier()) -> - {ok, route_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_route_tables(ctx:t(), route_pb:list_route_tables_request()) -> - {ok, route_pb:list_route_tables_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_route_table(ctx:t(), route_pb:create_route_table_request()) -> - {ok, route_pb:route_table(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_route_table(ctx:t(), route_pb:route_table_identifier()) -> - {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_route(ctx:t(), route_pb:route_identifier()) -> - {ok, route_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_routes(ctx:t(), route_pb:list_routes_request()) -> - {ok, route_pb:list_routes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback put_route(ctx:t(), route_pb:put_route_request()) -> - {ok, route_pb:route(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_route(ctx:t(), route_pb:route_identifier()) -> - {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback sync(ctx:t(), route_pb:sync_request()) -> - {ok, route_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/route_service_client.erl b/virtuerl/src/pb/route_service_client.erl deleted file mode 100644 index c36b8bf..0000000 --- a/virtuerl/src/pb/route_service_client.erl +++ /dev/null @@ -1,187 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service RouteService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(route_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'RouteService'). --define(PROTO_MODULE, 'route_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_route_table(route_pb:route_table_identifier()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Input) -> - get_route_table(ctx:new(), Input, #{}). - --spec get_route_table(ctx:t() | route_pb:route_table_identifier(), route_pb:route_table_identifier() | grpcbox_client:options()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - get_route_table(Ctx, Input, #{}); -get_route_table(Input, Options) -> - get_route_table(ctx:new(), Input, Options). - --spec get_route_table(ctx:t(), route_pb:route_table_identifier(), grpcbox_client:options()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/GetRouteTable">>, Input, ?DEF(route_table_identifier, route_table, <<"RouteTableIdentifier">>), Options). - -%% @doc Unary RPC --spec list_route_tables(route_pb:list_route_tables_request()) -> - {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Input) -> - list_route_tables(ctx:new(), Input, #{}). - --spec list_route_tables(ctx:t() | route_pb:list_route_tables_request(), route_pb:list_route_tables_request() | grpcbox_client:options()) -> - {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Ctx, Input) when ?is_ctx(Ctx) -> - list_route_tables(Ctx, Input, #{}); -list_route_tables(Input, Options) -> - list_route_tables(ctx:new(), Input, Options). - --spec list_route_tables(ctx:t(), route_pb:list_route_tables_request(), grpcbox_client:options()) -> - {ok, route_pb:list_route_tables_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_route_tables(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/ListRouteTables">>, Input, ?DEF(list_route_tables_request, list_route_tables_response, <<"ListRouteTablesRequest">>), Options). - -%% @doc Unary RPC --spec create_route_table(route_pb:create_route_table_request()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Input) -> - create_route_table(ctx:new(), Input, #{}). - --spec create_route_table(ctx:t() | route_pb:create_route_table_request(), route_pb:create_route_table_request() | grpcbox_client:options()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - create_route_table(Ctx, Input, #{}); -create_route_table(Input, Options) -> - create_route_table(ctx:new(), Input, Options). - --spec create_route_table(ctx:t(), route_pb:create_route_table_request(), grpcbox_client:options()) -> - {ok, route_pb:route_table(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/CreateRouteTable">>, Input, ?DEF(create_route_table_request, route_table, <<"CreateRouteTableRequest">>), Options). - -%% @doc Unary RPC --spec delete_route_table(route_pb:route_table_identifier()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Input) -> - delete_route_table(ctx:new(), Input, #{}). - --spec delete_route_table(ctx:t() | route_pb:route_table_identifier(), route_pb:route_table_identifier() | grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Ctx, Input) when ?is_ctx(Ctx) -> - delete_route_table(Ctx, Input, #{}); -delete_route_table(Input, Options) -> - delete_route_table(ctx:new(), Input, Options). - --spec delete_route_table(ctx:t(), route_pb:route_table_identifier(), grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route_table(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/DeleteRouteTable">>, Input, ?DEF(route_table_identifier, empty, <<"RouteTableIdentifier">>), Options). - -%% @doc Unary RPC --spec get_route(route_pb:route_identifier()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Input) -> - get_route(ctx:new(), Input, #{}). - --spec get_route(ctx:t() | route_pb:route_identifier(), route_pb:route_identifier() | grpcbox_client:options()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Ctx, Input) when ?is_ctx(Ctx) -> - get_route(Ctx, Input, #{}); -get_route(Input, Options) -> - get_route(ctx:new(), Input, Options). - --spec get_route(ctx:t(), route_pb:route_identifier(), grpcbox_client:options()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/GetRoute">>, Input, ?DEF(route_identifier, route, <<"RouteIdentifier">>), Options). - -%% @doc Unary RPC --spec list_routes(route_pb:list_routes_request()) -> - {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Input) -> - list_routes(ctx:new(), Input, #{}). - --spec list_routes(ctx:t() | route_pb:list_routes_request(), route_pb:list_routes_request() | grpcbox_client:options()) -> - {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Ctx, Input) when ?is_ctx(Ctx) -> - list_routes(Ctx, Input, #{}); -list_routes(Input, Options) -> - list_routes(ctx:new(), Input, Options). - --spec list_routes(ctx:t(), route_pb:list_routes_request(), grpcbox_client:options()) -> - {ok, route_pb:list_routes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_routes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/ListRoutes">>, Input, ?DEF(list_routes_request, list_routes_response, <<"ListRoutesRequest">>), Options). - -%% @doc Unary RPC --spec put_route(route_pb:put_route_request()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Input) -> - put_route(ctx:new(), Input, #{}). - --spec put_route(ctx:t() | route_pb:put_route_request(), route_pb:put_route_request() | grpcbox_client:options()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Ctx, Input) when ?is_ctx(Ctx) -> - put_route(Ctx, Input, #{}); -put_route(Input, Options) -> - put_route(ctx:new(), Input, Options). - --spec put_route(ctx:t(), route_pb:put_route_request(), grpcbox_client:options()) -> - {ok, route_pb:route(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -put_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/PutRoute">>, Input, ?DEF(put_route_request, route, <<"PutRouteRequest">>), Options). - -%% @doc Unary RPC --spec delete_route(route_pb:route_identifier()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Input) -> - delete_route(ctx:new(), Input, #{}). - --spec delete_route(ctx:t() | route_pb:route_identifier(), route_pb:route_identifier() | grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Ctx, Input) when ?is_ctx(Ctx) -> - delete_route(Ctx, Input, #{}); -delete_route(Input, Options) -> - delete_route(ctx:new(), Input, Options). - --spec delete_route(ctx:t(), route_pb:route_identifier(), grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_route(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/DeleteRoute">>, Input, ?DEF(route_identifier, empty, <<"RouteIdentifier">>), Options). - -%% @doc Unary RPC --spec sync(route_pb:sync_request()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync(Input) -> - sync(ctx:new(), Input, #{}). - --spec sync(ctx:t() | route_pb:sync_request(), route_pb:sync_request() | grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync(Ctx, Input) when ?is_ctx(Ctx) -> - sync(Ctx, Input, #{}); -sync(Input, Options) -> - sync(ctx:new(), Input, Options). - --spec sync(ctx:t(), route_pb:sync_request(), grpcbox_client:options()) -> - {ok, route_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -sync(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/RouteService/Sync">>, Input, ?DEF(sync_request, empty, <<"SyncRequest">>), Options). - diff --git a/virtuerl/src/pb/volume_pb.erl b/virtuerl/src/pb/volume_pb.erl deleted file mode 100644 index 106a556..0000000 --- a/virtuerl/src/pb/volume_pb.erl +++ /dev/null @@ -1,2159 +0,0 @@ -%% -*- coding: utf-8 -*- -%% @private -%% Automatically generated, do not edit -%% Generated by gpb_compile version 4.19.8 -%% Version source: file --module(volume_pb). - --export([encode_msg/2, encode_msg/3]). --export([decode_msg/2, decode_msg/3]). --export([merge_msgs/3, merge_msgs/4]). --export([verify_msg/2, verify_msg/3]). --export([get_msg_defs/0]). --export([get_msg_names/0]). --export([get_group_names/0]). --export([get_msg_or_group_names/0]). --export([get_enum_names/0]). --export([find_msg_def/1, fetch_msg_def/1]). --export([find_enum_def/1, fetch_enum_def/1]). --export([enum_symbol_by_value/2, enum_value_by_symbol/2]). --export([get_service_names/0]). --export([get_service_def/1]). --export([get_rpc_names/1]). --export([find_rpc_def/2, fetch_rpc_def/2]). --export([fqbin_to_service_name/1]). --export([service_name_to_fqbin/1]). --export([fqbins_to_service_and_rpc_name/2]). --export([service_and_rpc_name_to_fqbins/2]). --export([fqbin_to_msg_name/1]). --export([msg_name_to_fqbin/1]). --export([fqbin_to_enum_name/1]). --export([enum_name_to_fqbin/1]). --export([get_package_name/0]). --export([uses_packages/0]). --export([source_basename/0]). --export([get_all_source_basenames/0]). --export([get_all_proto_names/0]). --export([get_msg_containment/1]). --export([get_pkg_containment/1]). --export([get_service_containment/1]). --export([get_rpc_containment/1]). --export([get_enum_containment/1]). --export([get_proto_by_msg_name_as_fqbin/1]). --export([get_proto_by_service_name_as_fqbin/1]). --export([get_proto_by_enum_name_as_fqbin/1]). --export([get_protos_by_pkg_name_as_fqbin/1]). --export([gpb_version_as_string/0, gpb_version_as_list/0]). --export([gpb_version_source/0]). - - -%% enumerated types - --export_type([]). - -%% message types --type get_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume() :: - #{id => unicode:chardata(), % = 1, optional - name => unicode:chardata(), % = 2, optional - size => non_neg_integer() % = 3, optional, 64 bits - }. - --type list_volumes_request() :: - #{host => unicode:chardata() % = 1, optional - }. - --type list_volumes_response() :: - #{volumes => [volume()] % = 1, repeated - }. - --type create_volume_request() :: - #{volume => volume(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type update_volume_request() :: - #{host => unicode:chardata(), % = 1, optional - volume => volume() % = 2, optional - }. - --type delete_volume_request() :: - #{uuid => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type volume_attachment_identifier() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - host => unicode:chardata() % = 3, optional - }. - --type volume_attachment() :: - #{domain_id => unicode:chardata(), % = 1, optional - volume_id => unicode:chardata(), % = 2, optional - disk_address => unicode:chardata() % = 3, optional - }. - --type list_volume_attachments_request() :: - #{domain_id => unicode:chardata(), % = 1, optional - host => unicode:chardata() % = 2, optional - }. - --type list_volume_attachments_response() :: - #{attachments => [volume_attachment()] % = 1, repeated - }. - --type empty() :: - #{ - }. - --export_type(['get_volume_request'/0, 'volume'/0, 'list_volumes_request'/0, 'list_volumes_response'/0, 'create_volume_request'/0, 'update_volume_request'/0, 'delete_volume_request'/0, 'volume_attachment_identifier'/0, 'volume_attachment'/0, 'list_volume_attachments_request'/0, 'list_volume_attachments_response'/0, 'empty'/0]). --type '$msg_name'() :: get_volume_request | volume | list_volumes_request | list_volumes_response | create_volume_request | update_volume_request | delete_volume_request | volume_attachment_identifier | volume_attachment | list_volume_attachments_request | list_volume_attachments_response | empty. --type '$msg'() :: get_volume_request() | volume() | list_volumes_request() | list_volumes_response() | create_volume_request() | update_volume_request() | delete_volume_request() | volume_attachment_identifier() | volume_attachment() | list_volume_attachments_request() | list_volume_attachments_response() | empty(). --export_type(['$msg_name'/0, '$msg'/0]). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/2}). --endif. --spec encode_msg('$msg'(), '$msg_name'()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). - --if(?OTP_RELEASE >= 24). --dialyzer({no_underspecs, encode_msg/3}). --endif. --spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). -encode_msg(Msg, MsgName, Opts) -> - case proplists:get_bool(verify, Opts) of - true -> verify_msg(Msg, MsgName, Opts); - false -> ok - end, - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - get_volume_request -> encode_msg_get_volume_request(id(Msg, TrUserData), TrUserData); - volume -> encode_msg_volume(id(Msg, TrUserData), TrUserData); - list_volumes_request -> encode_msg_list_volumes_request(id(Msg, TrUserData), TrUserData); - list_volumes_response -> encode_msg_list_volumes_response(id(Msg, TrUserData), TrUserData); - create_volume_request -> encode_msg_create_volume_request(id(Msg, TrUserData), TrUserData); - update_volume_request -> encode_msg_update_volume_request(id(Msg, TrUserData), TrUserData); - delete_volume_request -> encode_msg_delete_volume_request(id(Msg, TrUserData), TrUserData); - volume_attachment_identifier -> encode_msg_volume_attachment_identifier(id(Msg, TrUserData), TrUserData); - volume_attachment -> encode_msg_volume_attachment(id(Msg, TrUserData), TrUserData); - list_volume_attachments_request -> encode_msg_list_volume_attachments_request(id(Msg, TrUserData), TrUserData); - list_volume_attachments_response -> encode_msg_list_volume_attachments_response(id(Msg, TrUserData), TrUserData); - empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) - end. - - -encode_msg_get_volume_request(Msg, TrUserData) -> encode_msg_get_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_get_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume(Msg, TrUserData) -> encode_msg_volume(Msg, <<>>, TrUserData). - - -encode_msg_volume(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{name := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{size := F3} -> - begin - TrF3 = id(F3, TrUserData), - if TrF3 =:= 0 -> B2; - true -> e_varint(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volumes_request(Msg, TrUserData) -> encode_msg_list_volumes_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_request(#{} = M, Bin, TrUserData) -> - case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end. - -encode_msg_list_volumes_response(Msg, TrUserData) -> encode_msg_list_volumes_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volumes_response(#{} = M, Bin, TrUserData) -> - case M of - #{volumes := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volumes_response_volumes(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_create_volume_request(Msg, TrUserData) -> encode_msg_create_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_create_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{volume := F1} -> - begin - TrF1 = id(F1, TrUserData), - if TrF1 =:= undefined -> Bin; - true -> e_mfield_create_volume_request_volume(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_update_volume_request(Msg, TrUserData) -> encode_msg_update_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_update_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{host := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{volume := F2} -> - begin - TrF2 = id(F2, TrUserData), - if TrF2 =:= undefined -> B1; - true -> e_mfield_update_volume_request_volume(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_delete_volume_request(Msg, TrUserData) -> encode_msg_delete_volume_request(Msg, <<>>, TrUserData). - - -encode_msg_delete_volume_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{uuid := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_volume_attachment_identifier(Msg, TrUserData) -> encode_msg_volume_attachment_identifier(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment_identifier(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{host := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_volume_attachment(Msg, TrUserData) -> encode_msg_volume_attachment(Msg, <<>>, TrUserData). - - -encode_msg_volume_attachment(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - B2 = case M of - #{volume_id := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end, - case M of - #{disk_address := F3} -> - begin - TrF3 = id(F3, TrUserData), - case is_empty_string(TrF3) of - true -> B2; - false -> e_type_string(TrF3, <>, TrUserData) - end - end; - _ -> B2 - end. - -encode_msg_list_volume_attachments_request(Msg, TrUserData) -> encode_msg_list_volume_attachments_request(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_request(#{} = M, Bin, TrUserData) -> - B1 = case M of - #{domain_id := F1} -> - begin - TrF1 = id(F1, TrUserData), - case is_empty_string(TrF1) of - true -> Bin; - false -> e_type_string(TrF1, <>, TrUserData) - end - end; - _ -> Bin - end, - case M of - #{host := F2} -> - begin - TrF2 = id(F2, TrUserData), - case is_empty_string(TrF2) of - true -> B1; - false -> e_type_string(TrF2, <>, TrUserData) - end - end; - _ -> B1 - end. - -encode_msg_list_volume_attachments_response(Msg, TrUserData) -> encode_msg_list_volume_attachments_response(Msg, <<>>, TrUserData). - - -encode_msg_list_volume_attachments_response(#{} = M, Bin, TrUserData) -> - case M of - #{attachments := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_list_volume_attachments_response_attachments(TrF1, Bin, TrUserData) - end; - _ -> Bin - end. - -encode_msg_empty(_Msg, _TrUserData) -> <<>>. - -e_mfield_list_volumes_response_volumes(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volumes_response_volumes([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volumes_response_volumes(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volumes_response_volumes(Rest, Bin3, TrUserData); -e_field_list_volumes_response_volumes([], Bin, _TrUserData) -> Bin. - -e_mfield_create_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_update_volume_request_volume(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_mfield_list_volume_attachments_response_attachments(Msg, Bin, TrUserData) -> - SubBin = encode_msg_volume_attachment(Msg, <<>>, TrUserData), - Bin2 = e_varint(byte_size(SubBin), Bin), - <>. - -e_field_list_volume_attachments_response_attachments([Elem | Rest], Bin, TrUserData) -> - Bin2 = <>, - Bin3 = e_mfield_list_volume_attachments_response_attachments(id(Elem, TrUserData), Bin2, TrUserData), - e_field_list_volume_attachments_response_attachments(Rest, Bin3, TrUserData); -e_field_list_volume_attachments_response_attachments([], Bin, _TrUserData) -> Bin. - --compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). - --compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int32(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; -e_type_int64(Value, Bin, _TrUserData) -> - <> = <>, - e_varint(N, Bin). - --compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> <>; -e_type_bool(false, Bin, _TrUserData) -> <>; -e_type_bool(1, Bin, _TrUserData) -> <>; -e_type_bool(0, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_string/3}). -e_type_string(S, Bin, _TrUserData) -> - Utf8 = unicode:characters_to_binary(S), - Bin2 = e_varint(byte_size(Utf8), Bin), - <>. - --compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> - Bin2 = e_varint(byte_size(Bytes), Bin), - <>; -e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> - BytesBin = iolist_to_binary(Bytes), - Bin2 = e_varint(byte_size(BytesBin), Bin), - <>. - --compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> <>. - --compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> <>; -e_type_float(infinity, Bin, _) -> <>; -e_type_float('-infinity', Bin, _) -> <>; -e_type_float(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> <>; -e_type_double(infinity, Bin, _) -> <>; -e_type_double('-infinity', Bin, _) -> <>; -e_type_double(nan, Bin, _) -> <>. - --compile({nowarn_unused_function,e_unknown_elems/2}). -e_unknown_elems([Elem | Rest], Bin) -> - BinR = case Elem of - {varint, FNum, N} -> - BinF = e_varint(FNum bsl 3, Bin), - e_varint(N, BinF); - {length_delimited, FNum, Data} -> - BinF = e_varint(FNum bsl 3 bor 2, Bin), - BinL = e_varint(byte_size(Data), BinF), - <>; - {group, FNum, GroupFields} -> - Bin1 = e_varint(FNum bsl 3 bor 3, Bin), - Bin2 = e_unknown_elems(GroupFields, Bin1), - e_varint(FNum bsl 3 bor 4, Bin2); - {fixed32, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 5, Bin), - <>; - {fixed64, FNum, V} -> - BinF = e_varint(FNum bsl 3 bor 1, Bin), - <> - end, - e_unknown_elems(Rest, BinR); -e_unknown_elems([], Bin) -> Bin. - --compile({nowarn_unused_function,e_varint/3}). -e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). - --compile({nowarn_unused_function,e_varint/2}). -e_varint(N, Bin) when N =< 127 -> <>; -e_varint(N, Bin) -> - Bin2 = <>, - e_varint(N bsr 7, Bin2). - -is_empty_string("") -> true; -is_empty_string(<<>>) -> true; -is_empty_string(L) when is_list(L) -> not string_has_chars(L); -is_empty_string(B) when is_binary(B) -> false. - -string_has_chars([C | _]) when is_integer(C) -> true; -string_has_chars([H | T]) -> - case string_has_chars(H) of - true -> true; - false -> string_has_chars(T) - end; -string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; -string_has_chars(C) when is_integer(C) -> true; -string_has_chars(<<>>) -> false; -string_has_chars([]) -> false. - - -decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). - -decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> - TrUserData = proplists:get_value(user_data, Opts), - decode_msg_1_catch(Bin, MsgName, TrUserData). - --ifdef('OTP_RELEASE'). -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason:StackTrace -> - erlang:raise(error, Reason, StackTrace); - Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --else. -decode_msg_1_catch(Bin, MsgName, TrUserData) -> - try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch - error:{gpb_error,_}=Reason -> - erlang:raise(error, Reason, - erlang:get_stacktrace()); - Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) - end. --endif. - -decode_msg_2_doit(get_volume_request, Bin, TrUserData) -> id(decode_msg_get_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume, Bin, TrUserData) -> id(decode_msg_volume(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_request, Bin, TrUserData) -> id(decode_msg_list_volumes_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volumes_response, Bin, TrUserData) -> id(decode_msg_list_volumes_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(create_volume_request, Bin, TrUserData) -> id(decode_msg_create_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(update_volume_request, Bin, TrUserData) -> id(decode_msg_update_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(delete_volume_request, Bin, TrUserData) -> id(decode_msg_delete_volume_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment_identifier, Bin, TrUserData) -> id(decode_msg_volume_attachment_identifier(Bin, TrUserData), TrUserData); -decode_msg_2_doit(volume_attachment, Bin, TrUserData) -> id(decode_msg_volume_attachment(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_request, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_request(Bin, TrUserData), TrUserData); -decode_msg_2_doit(list_volume_attachments_response, Bin, TrUserData) -> id(decode_msg_list_volume_attachments_response(Bin, TrUserData), TrUserData); -decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). - - - -decode_msg_get_volume_request(Bin, TrUserData) -> dfp_read_field_def_get_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_get_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_get_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_get_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_get_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_get_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_get_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_get_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_get_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_get_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_get_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_get_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_get_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_get_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_get_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_get_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_get_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_get_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_get_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_get_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_get_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_get_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_get_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_get_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume(Bin, TrUserData) -> dfp_read_field_def_volume(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). - -dfp_read_field_def_volume(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_size(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}; -dfp_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 24 -> d_field_volume_size(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{id => F@_1, name => F@_2, size => F@_3}. - -d_field_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_size(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_size(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_size(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = {id((X bsl N + Acc) band 18446744073709551615, TrUserData), Rest}, - dfp_read_field_def_volume(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volumes_request(Bin, TrUserData) -> dfp_read_field_def_list_volumes_request(Bin, 0, 0, 0, id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_request_host(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}; -dfp_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_request(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_request_host(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_request(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_request(<<>>, 0, 0, _, F@_1, _) -> #{host => F@_1}. - -d_field_list_volumes_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_request(RestF, 0, 0, F, NewFValue, TrUserData). - -skip_varint_list_volumes_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_request(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_request(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_request(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_request(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_request(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_list_volumes_response(Bin, TrUserData) -> dfp_read_field_def_list_volumes_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volumes_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volumes_response_volumes(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volumes_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volumes_response_volumes(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volumes_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volumes_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{volumes => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volumes_response_volumes(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volumes_response_volumes(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volumes_response_volumes(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volumes_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volumes_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volumes_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volumes_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volumes_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volumes_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volumes_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volumes_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volumes_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volumes_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volumes_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volumes_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_create_volume_request(Bin, TrUserData) -> dfp_read_field_def_create_volume_request(Bin, 0, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_create_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_create_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end; -dfp_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_create_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_create_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_create_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_create_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_create_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_2}, - if F@_1 == '$undef' -> S1; - true -> S1#{volume => F@_1} - end. - -d_field_create_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, - 0, - 0, - F, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - F@_2, - TrUserData). - -d_field_create_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_create_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_create_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_create_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_create_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_create_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_create_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_create_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_create_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_create_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_create_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_create_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_create_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_create_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_create_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_update_volume_request(Bin, TrUserData) -> dfp_read_field_def_update_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_update_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_update_volume_request_volume(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end; -dfp_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_update_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_update_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_update_volume_request_volume(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_update_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_update_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> - S1 = #{host => F@_1}, - if F@_2 == '$undef' -> S1; - true -> S1#{volume => F@_2} - end. - -d_field_update_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_update_volume_request_volume(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_update_volume_request_volume(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_update_volume_request_volume(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_update_volume_request(RestF, - 0, - 0, - F, - F@_1, - if Prev == '$undef' -> NewFValue; - true -> merge_msg_volume(Prev, NewFValue, TrUserData) - end, - TrUserData). - -skip_varint_update_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_update_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_update_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_update_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_update_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_update_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_update_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_update_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_update_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_update_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_update_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_delete_volume_request(Bin, TrUserData) -> dfp_read_field_def_delete_volume_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_delete_volume_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_uuid(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_delete_volume_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}; -dfp_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_delete_volume_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_delete_volume_request_uuid(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_delete_volume_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_delete_volume_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_delete_volume_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{uuid => F@_1, host => F@_2}. - -d_field_delete_volume_request_uuid(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_uuid(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_uuid(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_delete_volume_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_delete_volume_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_delete_volume_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_delete_volume_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_delete_volume_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_delete_volume_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_delete_volume_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_delete_volume_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_delete_volume_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_delete_volume_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_delete_volume_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_delete_volume_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_delete_volume_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_delete_volume_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_delete_volume_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_volume_attachment_identifier(Bin, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment_identifier(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_identifier_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}; -dfp_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment_identifier(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_identifier_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_identifier_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_identifier_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment_identifier(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment_identifier(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, host => F@_3}. - -d_field_volume_attachment_identifier_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_identifier_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_identifier_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_identifier_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_identifier_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment_identifier(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment_identifier(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment_identifier(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment_identifier(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment_identifier(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment_identifier(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment_identifier(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment_identifier(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment_identifier(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment_identifier(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment_identifier(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment_identifier(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_volume_attachment(Bin, TrUserData) -> dfp_read_field_def_volume_attachment(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_volume_attachment(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_volume_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_volume_attachment_disk_address(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -dfp_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}; -dfp_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_volume_attachment(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -dg_read_field_def_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_volume_attachment_domain_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 18 -> d_field_volume_attachment_volume_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - 26 -> d_field_volume_attachment_disk_address(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 1 -> skip_64_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 2 -> skip_length_delimited_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 3 -> skip_group_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); - 5 -> skip_32_volume_attachment(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) - end - end; -dg_read_field_def_volume_attachment(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #{domain_id => F@_1, volume_id => F@_2, disk_address => F@_3}. - -d_field_volume_attachment_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). - -d_field_volume_attachment_volume_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_volume_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_volume_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). - -d_field_volume_attachment_disk_address(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_volume_attachment_disk_address(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -d_field_volume_attachment_disk_address(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_volume_attachment(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). - -skip_varint_volume_attachment(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); -skip_varint_volume_attachment(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_length_delimited_volume_attachment(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_volume_attachment(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_volume_attachment(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_volume_attachment(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). - -skip_group_volume_attachment(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_volume_attachment(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). - -skip_32_volume_attachment(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -skip_64_volume_attachment(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_volume_attachment(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). - -decode_msg_list_volume_attachments_request(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_request(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_domain_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_list_volume_attachments_request_host(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -dfp_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}; -dfp_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_list_volume_attachments_request(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). - -dg_read_field_def_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -dg_read_field_def_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_request_domain_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - 18 -> d_field_list_volume_attachments_request_host(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 1 -> skip_64_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 3 -> skip_group_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); - 5 -> skip_32_list_volume_attachments_request(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_request(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{domain_id => F@_1, host => F@_2}. - -d_field_list_volume_attachments_request_domain_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_domain_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_domain_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). - -d_field_list_volume_attachments_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_list_volume_attachments_request_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -d_field_list_volume_attachments_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_request(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). - -skip_varint_list_volume_attachments_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); -skip_varint_list_volume_attachments_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_length_delimited_list_volume_attachments_request(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_request(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); -skip_length_delimited_list_volume_attachments_request(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_request(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). - -skip_group_list_volume_attachments_request(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_request(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). - -skip_32_list_volume_attachments_request(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -skip_64_list_volume_attachments_request(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_list_volume_attachments_request(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). - -decode_msg_list_volume_attachments_response(Bin, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Bin, 0, 0, 0, id([], TrUserData), TrUserData). - -dfp_read_field_def_list_volume_attachments_response(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_list_volume_attachments_response_attachments(Rest, Z1, Z2, F, F@_1, TrUserData); -dfp_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end; -dfp_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_list_volume_attachments_response(Other, Z1, Z2, F, F@_1, TrUserData). - -dg_read_field_def_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -dg_read_field_def_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) -> - Key = X bsl N + Acc, - case Key of - 10 -> d_field_list_volume_attachments_response_attachments(Rest, 0, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 1 -> skip_64_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 2 -> skip_length_delimited_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 3 -> skip_group_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); - 5 -> skip_32_list_volume_attachments_response(Rest, 0, 0, Key bsr 3, F@_1, TrUserData) - end - end; -dg_read_field_def_list_volume_attachments_response(<<>>, 0, 0, _, R1, TrUserData) -> - S1 = #{}, - if R1 == '$undef' -> S1; - true -> S1#{attachments => lists_reverse(R1, TrUserData)} - end. - -d_field_list_volume_attachments_response_attachments(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_list_volume_attachments_response_attachments(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -d_field_list_volume_attachments_response_attachments(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) -> - {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_volume_attachment(Bs, TrUserData), TrUserData), Rest2} end, - dfp_read_field_def_list_volume_attachments_response(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), TrUserData). - -skip_varint_list_volume_attachments_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData); -skip_varint_list_volume_attachments_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_length_delimited_list_volume_attachments_response(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_volume_attachments_response(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData); -skip_length_delimited_list_volume_attachments_response(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_list_volume_attachments_response(Rest2, 0, 0, F, F@_1, TrUserData). - -skip_group_list_volume_attachments_response(Bin, _, Z2, FNum, F@_1, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_list_volume_attachments_response(Rest, 0, Z2, FNum, F@_1, TrUserData). - -skip_32_list_volume_attachments_response(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -skip_64_list_volume_attachments_response(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_list_volume_attachments_response(Rest, Z1, Z2, F, F@_1, TrUserData). - -decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, 0, TrUserData). - -dfp_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}; -dfp_read_field_def_empty(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, F, TrUserData). - -dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> - Key = X bsl N + Acc, - case Key band 7 of - 0 -> skip_varint_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 1 -> skip_64_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 2 -> skip_length_delimited_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 3 -> skip_group_empty(Rest, 0, 0, Key bsr 3, TrUserData); - 5 -> skip_32_empty(Rest, 0, 0, Key bsr 3, TrUserData) - end; -dg_read_field_def_empty(<<>>, 0, 0, _, _) -> #{}. - -skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, F, TrUserData); -skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, F, TrUserData); -skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) -> - Length = X bsl N + Acc, - <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_empty(Rest2, 0, 0, F, TrUserData). - -skip_group_empty(Bin, _, Z2, FNum, TrUserData) -> - {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_empty(Rest, 0, Z2, FNum, TrUserData). - -skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, F, TrUserData). - -read_group(Bin, FieldNum) -> - {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), - <> = Bin, - {Group, Rest}. - -%% Like skipping over fields, but record the total length, -%% Each field is <(FieldNum bsl 3) bor FieldType> ++ -%% Record the length because varints may be non-optimally encoded. -%% -%% Groups can be nested, but assume the same FieldNum cannot be nested -%% because group field numbers are shared with the rest of the fields -%% numbers. Thus we can search just for an group-end with the same -%% field number. -%% -%% (The only time the same group field number could occur would -%% be in a nested sub message, but then it would be inside a -%% length-delimited entry, which we skip-read by length.) -read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) - when N < (32-7) -> - read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); -read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, - FieldNum) -> - Key = X bsl N + Acc, - TagLen1 = TagLen + 1, - case {Key bsr 3, Key band 7} of - {FieldNum, 4} -> % 4 = group_end - {NumBytes, TagLen1}; - {_, 0} -> % 0 = varint - read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); - {_, 1} -> % 1 = bits64 - <<_:64, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); - {_, 2} -> % 2 = length_delimited - read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); - {_, 3} -> % 3 = group_start - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 4} -> % 4 = group_end - read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); - {_, 5} -> % 5 = bits32 - <<_:32, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) - end. - -read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); -read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> - read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). - -read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) - when N < (64-7) -> - read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); -read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> - Len = X bsl N + Acc, - NumBytes1 = NumBytes + 1, - <<_:Len/binary, Tl2/binary>> = Tl, - read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). - -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). - -merge_msgs(Prev, New, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - get_volume_request -> merge_msg_get_volume_request(Prev, New, TrUserData); - volume -> merge_msg_volume(Prev, New, TrUserData); - list_volumes_request -> merge_msg_list_volumes_request(Prev, New, TrUserData); - list_volumes_response -> merge_msg_list_volumes_response(Prev, New, TrUserData); - create_volume_request -> merge_msg_create_volume_request(Prev, New, TrUserData); - update_volume_request -> merge_msg_update_volume_request(Prev, New, TrUserData); - delete_volume_request -> merge_msg_delete_volume_request(Prev, New, TrUserData); - volume_attachment_identifier -> merge_msg_volume_attachment_identifier(Prev, New, TrUserData); - volume_attachment -> merge_msg_volume_attachment(Prev, New, TrUserData); - list_volume_attachments_request -> merge_msg_list_volume_attachments_request(Prev, New, TrUserData); - list_volume_attachments_response -> merge_msg_list_volume_attachments_response(Prev, New, TrUserData); - empty -> merge_msg_empty(Prev, New, TrUserData) - end. - --compile({nowarn_unused_function,merge_msg_get_volume_request/3}). -merge_msg_get_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume/3}). -merge_msg_volume(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{id := NFid}} -> S1#{id => NFid}; - {#{id := PFid}, _} -> S1#{id => PFid}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{name := NFname}} -> S2#{name => NFname}; - {#{name := PFname}, _} -> S2#{name => PFname}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{size := NFsize}} -> S3#{size => NFsize}; - {#{size := PFsize}, _} -> S3#{size => PFsize}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_request/3}). -merge_msg_list_volumes_request(PMsg, NMsg, _) -> - S1 = #{}, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end. - --compile({nowarn_unused_function,merge_msg_list_volumes_response/3}). -merge_msg_list_volumes_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{volumes := PFvolumes}, #{volumes := NFvolumes}} -> S1#{volumes => 'erlang_++'(PFvolumes, NFvolumes, TrUserData)}; - {_, #{volumes := NFvolumes}} -> S1#{volumes => NFvolumes}; - {#{volumes := PFvolumes}, _} -> S1#{volumes => PFvolumes}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_create_volume_request/3}). -merge_msg_create_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S1#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S1#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S1#{volume => PFvolume}; - {_, _} -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_update_volume_request/3}). -merge_msg_update_volume_request(PMsg, NMsg, TrUserData) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S1#{host => NFhost}; - {#{host := PFhost}, _} -> S1#{host => PFhost}; - _ -> S1 - end, - case {PMsg, NMsg} of - {#{volume := PFvolume}, #{volume := NFvolume}} -> S2#{volume => merge_msg_volume(PFvolume, NFvolume, TrUserData)}; - {_, #{volume := NFvolume}} -> S2#{volume => NFvolume}; - {#{volume := PFvolume}, _} -> S2#{volume => PFvolume}; - {_, _} -> S2 - end. - --compile({nowarn_unused_function,merge_msg_delete_volume_request/3}). -merge_msg_delete_volume_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{uuid := NFuuid}} -> S1#{uuid => NFuuid}; - {#{uuid := PFuuid}, _} -> S1#{uuid => PFuuid}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment_identifier/3}). -merge_msg_volume_attachment_identifier(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S3#{host => NFhost}; - {#{host := PFhost}, _} -> S3#{host => PFhost}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_volume_attachment/3}). -merge_msg_volume_attachment(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - S3 = case {PMsg, NMsg} of - {_, #{volume_id := NFvolume_id}} -> S2#{volume_id => NFvolume_id}; - {#{volume_id := PFvolume_id}, _} -> S2#{volume_id => PFvolume_id}; - _ -> S2 - end, - case {PMsg, NMsg} of - {_, #{disk_address := NFdisk_address}} -> S3#{disk_address => NFdisk_address}; - {#{disk_address := PFdisk_address}, _} -> S3#{disk_address => PFdisk_address}; - _ -> S3 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_request/3}). -merge_msg_list_volume_attachments_request(PMsg, NMsg, _) -> - S1 = #{}, - S2 = case {PMsg, NMsg} of - {_, #{domain_id := NFdomain_id}} -> S1#{domain_id => NFdomain_id}; - {#{domain_id := PFdomain_id}, _} -> S1#{domain_id => PFdomain_id}; - _ -> S1 - end, - case {PMsg, NMsg} of - {_, #{host := NFhost}} -> S2#{host => NFhost}; - {#{host := PFhost}, _} -> S2#{host => PFhost}; - _ -> S2 - end. - --compile({nowarn_unused_function,merge_msg_list_volume_attachments_response/3}). -merge_msg_list_volume_attachments_response(PMsg, NMsg, TrUserData) -> - S1 = #{}, - case {PMsg, NMsg} of - {#{attachments := PFattachments}, #{attachments := NFattachments}} -> S1#{attachments => 'erlang_++'(PFattachments, NFattachments, TrUserData)}; - {_, #{attachments := NFattachments}} -> S1#{attachments => NFattachments}; - {#{attachments := PFattachments}, _} -> S1#{attachments => PFattachments}; - {_, _} -> S1 - end. - --compile({nowarn_unused_function,merge_msg_empty/3}). -merge_msg_empty(_Prev, New, _TrUserData) -> New. - - -verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). - -verify_msg(Msg, MsgName, Opts) -> - TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - get_volume_request -> v_msg_get_volume_request(Msg, [MsgName], TrUserData); - volume -> v_msg_volume(Msg, [MsgName], TrUserData); - list_volumes_request -> v_msg_list_volumes_request(Msg, [MsgName], TrUserData); - list_volumes_response -> v_msg_list_volumes_response(Msg, [MsgName], TrUserData); - create_volume_request -> v_msg_create_volume_request(Msg, [MsgName], TrUserData); - update_volume_request -> v_msg_update_volume_request(Msg, [MsgName], TrUserData); - delete_volume_request -> v_msg_delete_volume_request(Msg, [MsgName], TrUserData); - volume_attachment_identifier -> v_msg_volume_attachment_identifier(Msg, [MsgName], TrUserData); - volume_attachment -> v_msg_volume_attachment(Msg, [MsgName], TrUserData); - list_volume_attachments_request -> v_msg_list_volume_attachments_request(Msg, [MsgName], TrUserData); - list_volume_attachments_response -> v_msg_list_volume_attachments_response(Msg, [MsgName], TrUserData); - empty -> v_msg_empty(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) - end. - - --compile({nowarn_unused_function,v_msg_get_volume_request/3}). --dialyzer({nowarn_function,v_msg_get_volume_request/3}). -v_msg_get_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_get_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), get_volume_request}, M, Path); -v_msg_get_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, get_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume/3}). --dialyzer({nowarn_function,v_msg_volume/3}). -v_msg_volume(#{} = M, Path, TrUserData) -> - case M of - #{id := F1} -> v_type_string(F1, [id | Path], TrUserData); - _ -> ok - end, - case M of - #{name := F2} -> v_type_string(F2, [name | Path], TrUserData); - _ -> ok - end, - case M of - #{size := F3} -> v_type_uint64(F3, [size | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (id) -> ok; - (name) -> ok; - (size) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume}, M, Path); -v_msg_volume(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_request/3}). --dialyzer({nowarn_function,v_msg_list_volumes_request/3}). -v_msg_list_volumes_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_request}, M, Path); -v_msg_list_volumes_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volumes_response/3}). --dialyzer({nowarn_function,v_msg_list_volumes_response/3}). -v_msg_list_volumes_response(#{} = M, Path, TrUserData) -> - case M of - #{volumes := F1} -> - if is_list(F1) -> - _ = [v_msg_volume(Elem, [volumes | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume}}, F1, [volumes | Path]) - end; - _ -> ok - end, - lists:foreach(fun (volumes) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volumes_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volumes_response}, M, Path); -v_msg_list_volumes_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volumes_response}, X, Path). - --compile({nowarn_unused_function,v_msg_create_volume_request/3}). --dialyzer({nowarn_function,v_msg_create_volume_request/3}). -v_msg_create_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{volume := F1} -> v_msg_volume(F1, [volume | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (volume) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_create_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), create_volume_request}, M, Path); -v_msg_create_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, create_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_update_volume_request/3}). --dialyzer({nowarn_function,v_msg_update_volume_request/3}). -v_msg_update_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); - _ -> ok - end, - case M of - #{volume := F2} -> v_msg_volume(F2, [volume | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (host) -> ok; - (volume) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_update_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), update_volume_request}, M, Path); -v_msg_update_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, update_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_delete_volume_request/3}). --dialyzer({nowarn_function,v_msg_delete_volume_request/3}). -v_msg_delete_volume_request(#{} = M, Path, TrUserData) -> - case M of - #{uuid := F1} -> v_type_string(F1, [uuid | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (uuid) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_delete_volume_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), delete_volume_request}, M, Path); -v_msg_delete_volume_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, delete_volume_request}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment_identifier/3}). --dialyzer({nowarn_function,v_msg_volume_attachment_identifier/3}). -v_msg_volume_attachment_identifier(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F3} -> v_type_string(F3, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment_identifier(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment_identifier}, M, Path); -v_msg_volume_attachment_identifier(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment_identifier}, X, Path). - --compile({nowarn_unused_function,v_msg_volume_attachment/3}). --dialyzer({nowarn_function,v_msg_volume_attachment/3}). -v_msg_volume_attachment(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{volume_id := F2} -> v_type_string(F2, [volume_id | Path], TrUserData); - _ -> ok - end, - case M of - #{disk_address := F3} -> v_type_string(F3, [disk_address | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (volume_id) -> ok; - (disk_address) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_volume_attachment(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), volume_attachment}, M, Path); -v_msg_volume_attachment(X, Path, _TrUserData) -> mk_type_error({expected_msg, volume_attachment}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_request/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_request/3}). -v_msg_list_volume_attachments_request(#{} = M, Path, TrUserData) -> - case M of - #{domain_id := F1} -> v_type_string(F1, [domain_id | Path], TrUserData); - _ -> ok - end, - case M of - #{host := F2} -> v_type_string(F2, [host | Path], TrUserData); - _ -> ok - end, - lists:foreach(fun (domain_id) -> ok; - (host) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_request}, M, Path); -v_msg_list_volume_attachments_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_request}, X, Path). - --compile({nowarn_unused_function,v_msg_list_volume_attachments_response/3}). --dialyzer({nowarn_function,v_msg_list_volume_attachments_response/3}). -v_msg_list_volume_attachments_response(#{} = M, Path, TrUserData) -> - case M of - #{attachments := F1} -> - if is_list(F1) -> - _ = [v_msg_volume_attachment(Elem, [attachments | Path], TrUserData) || Elem <- F1], - ok; - true -> mk_type_error({invalid_list_of, {msg, volume_attachment}}, F1, [attachments | Path]) - end; - _ -> ok - end, - lists:foreach(fun (attachments) -> ok; - (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), - ok; -v_msg_list_volume_attachments_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_volume_attachments_response}, M, Path); -v_msg_list_volume_attachments_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_volume_attachments_response}, X, Path). - --compile({nowarn_unused_function,v_msg_empty/3}). --dialyzer({nowarn_function,v_msg_empty/3}). -v_msg_empty(#{} = M, Path, _) -> - lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), - ok; -v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); -v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). - --compile({nowarn_unused_function,v_type_uint64/3}). --dialyzer({nowarn_function,v_type_uint64/3}). -v_type_uint64(N, _Path, _TrUserData) when 0 =< N, N =< 18446744073709551615 -> ok; -v_type_uint64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, uint64, unsigned, 64}, N, Path); -v_type_uint64(X, Path, _TrUserData) -> mk_type_error({bad_integer, uint64, unsigned, 64}, X, Path). - --compile({nowarn_unused_function,v_type_string/3}). --dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> - try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) - catch - error:badarg -> mk_type_error(bad_unicode_string, S, Path) - end; -v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). - --compile({nowarn_unused_function,mk_type_error/3}). --spec mk_type_error(_, _, list()) -> no_return(). -mk_type_error(Error, ValueSeen, Path) -> - Path2 = prettify_path(Path), - erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). - - --compile({nowarn_unused_function,prettify_path/1}). --dialyzer({nowarn_function,prettify_path/1}). -prettify_path([]) -> top_level; -prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). - - --compile({nowarn_unused_function,id/2}). --compile({inline,id/2}). -id(X, _TrUserData) -> X. - --compile({nowarn_unused_function,v_ok/3}). --compile({inline,v_ok/3}). -v_ok(_Value, _Path, _TrUserData) -> ok. - --compile({nowarn_unused_function,m_overwrite/3}). --compile({inline,m_overwrite/3}). -m_overwrite(_Prev, New, _TrUserData) -> New. - --compile({nowarn_unused_function,cons/3}). --compile({inline,cons/3}). -cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. - --compile({nowarn_unused_function,lists_reverse/2}). --compile({inline,lists_reverse/2}). -'lists_reverse'(L, _TrUserData) -> lists:reverse(L). --compile({nowarn_unused_function,'erlang_++'/3}). --compile({inline,'erlang_++'/3}). -'erlang_++'(A, B, _TrUserData) -> A ++ B. - - -get_msg_defs() -> - [{{msg, get_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume}, - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]}, - {{msg, list_volumes_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volumes_response}, [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]}, - {{msg, create_volume_request}, [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, update_volume_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]}, - {{msg, delete_volume_request}, [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment_identifier}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, volume_attachment}, - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_request}, [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, - {{msg, list_volume_attachments_response}, [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]}, - {{msg, empty}, []}]. - - -get_msg_names() -> - [get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - empty]. - - -get_group_names() -> []. - - -get_msg_or_group_names() -> - [get_volume_request, - volume, - list_volumes_request, - list_volumes_response, - create_volume_request, - update_volume_request, - delete_volume_request, - volume_attachment_identifier, - volume_attachment, - list_volume_attachments_request, - list_volume_attachments_response, - empty]. - - -get_enum_names() -> []. - - -fetch_msg_def(MsgName) -> - case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) - end. - - --spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). - - -find_msg_def(get_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume) -> - [#{name => id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => size, fnum => 3, rnum => 4, type => uint64, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volumes_response) -> [#{name => volumes, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => repeated, opts => []}]; -find_msg_def(create_volume_request) -> [#{name => volume, fnum => 1, rnum => 2, type => {msg, volume}, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(update_volume_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => volume, fnum => 2, rnum => 3, type => {msg, volume}, occurrence => optional, opts => []}]; -find_msg_def(delete_volume_request) -> [#{name => uuid, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment_identifier) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => host, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(volume_attachment) -> - [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, - #{name => volume_id, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, - #{name => disk_address, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_request) -> [#{name => domain_id, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => host, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; -find_msg_def(list_volume_attachments_response) -> [#{name => attachments, fnum => 1, rnum => 2, type => {msg, volume_attachment}, occurrence => repeated, opts => []}]; -find_msg_def(empty) -> []; -find_msg_def(_) -> error. - - -find_enum_def(_) -> error. - - --spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). - - --spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). - - - -get_service_names() -> ['VolumeService']. - - -get_service_def('VolumeService') -> - {{service, 'VolumeService'}, - [#{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}, - #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}, - #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}, - #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}, - #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}]}; -get_service_def(_) -> error. - - -get_rpc_names('VolumeService') -> ['GetVolume', 'ListVolumes', 'CreateVolume', 'UpdateVolume', 'DeleteVolume', 'ListVolumeAttachments', 'GetVolumeAttachment', 'AttachVolume', 'DetachVolume']; -get_rpc_names(_) -> error. - - -find_rpc_def('VolumeService', RpcName) -> find_rpc_def_VolumeService(RpcName); -find_rpc_def(_, _) -> error. - - -find_rpc_def_VolumeService('GetVolume') -> #{name => 'GetVolume', input => get_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumes') -> #{name => 'ListVolumes', input => list_volumes_request, output => list_volumes_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('CreateVolume') -> #{name => 'CreateVolume', input => create_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('UpdateVolume') -> #{name => 'UpdateVolume', input => update_volume_request, output => volume, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DeleteVolume') -> #{name => 'DeleteVolume', input => delete_volume_request, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('ListVolumeAttachments') -> #{name => 'ListVolumeAttachments', input => list_volume_attachments_request, output => list_volume_attachments_response, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('GetVolumeAttachment') -> #{name => 'GetVolumeAttachment', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('AttachVolume') -> #{name => 'AttachVolume', input => volume_attachment_identifier, output => volume_attachment, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService('DetachVolume') -> #{name => 'DetachVolume', input => volume_attachment_identifier, output => empty, input_stream => false, output_stream => false, opts => []}; -find_rpc_def_VolumeService(_) -> error. - - -fetch_rpc_def(ServiceName, RpcName) -> - case find_rpc_def(ServiceName, RpcName) of - Def when is_map(Def) -> Def; - error -> erlang:error({no_such_rpc, ServiceName, RpcName}) - end. - - -%% Convert a a fully qualified (ie with package name) service name -%% as a binary to a service name as an atom. -fqbin_to_service_name(<<"VolumeService">>) -> 'VolumeService'; -fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a service name as an atom to a fully qualified -%% (ie with package name) name as a binary. -service_name_to_fqbin('VolumeService') -> <<"VolumeService">>; -service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). - - -%% Convert a a fully qualified (ie with package name) service name -%% and an rpc name, both as binaries to a service name and an rpc -%% name, as atoms. -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolume">>) -> {'VolumeService', 'GetVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumes">>) -> {'VolumeService', 'ListVolumes'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"CreateVolume">>) -> {'VolumeService', 'CreateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"UpdateVolume">>) -> {'VolumeService', 'UpdateVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DeleteVolume">>) -> {'VolumeService', 'DeleteVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"ListVolumeAttachments">>) -> {'VolumeService', 'ListVolumeAttachments'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"GetVolumeAttachment">>) -> {'VolumeService', 'GetVolumeAttachment'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"AttachVolume">>) -> {'VolumeService', 'AttachVolume'}; -fqbins_to_service_and_rpc_name(<<"VolumeService">>, <<"DetachVolume">>) -> {'VolumeService', 'DetachVolume'}; -fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -%% Convert a service name and an rpc name, both as atoms, -%% to a fully qualified (ie with package name) service name and -%% an rpc name as binaries. -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolume') -> {<<"VolumeService">>, <<"GetVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumes') -> {<<"VolumeService">>, <<"ListVolumes">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'CreateVolume') -> {<<"VolumeService">>, <<"CreateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'UpdateVolume') -> {<<"VolumeService">>, <<"UpdateVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DeleteVolume') -> {<<"VolumeService">>, <<"DeleteVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'ListVolumeAttachments') -> {<<"VolumeService">>, <<"ListVolumeAttachments">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'GetVolumeAttachment') -> {<<"VolumeService">>, <<"GetVolumeAttachment">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'AttachVolume') -> {<<"VolumeService">>, <<"AttachVolume">>}; -service_and_rpc_name_to_fqbins('VolumeService', 'DetachVolume') -> {<<"VolumeService">>, <<"DetachVolume">>}; -service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). - - -fqbin_to_msg_name(<<"GetVolumeRequest">>) -> get_volume_request; -fqbin_to_msg_name(<<"Volume">>) -> volume; -fqbin_to_msg_name(<<"ListVolumesRequest">>) -> list_volumes_request; -fqbin_to_msg_name(<<"ListVolumesResponse">>) -> list_volumes_response; -fqbin_to_msg_name(<<"CreateVolumeRequest">>) -> create_volume_request; -fqbin_to_msg_name(<<"UpdateVolumeRequest">>) -> update_volume_request; -fqbin_to_msg_name(<<"DeleteVolumeRequest">>) -> delete_volume_request; -fqbin_to_msg_name(<<"VolumeAttachmentIdentifier">>) -> volume_attachment_identifier; -fqbin_to_msg_name(<<"VolumeAttachment">>) -> volume_attachment; -fqbin_to_msg_name(<<"ListVolumeAttachmentsRequest">>) -> list_volume_attachments_request; -fqbin_to_msg_name(<<"ListVolumeAttachmentsResponse">>) -> list_volume_attachments_response; -fqbin_to_msg_name(<<"google.protobuf.Empty">>) -> empty; -fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). - - -msg_name_to_fqbin(get_volume_request) -> <<"GetVolumeRequest">>; -msg_name_to_fqbin(volume) -> <<"Volume">>; -msg_name_to_fqbin(list_volumes_request) -> <<"ListVolumesRequest">>; -msg_name_to_fqbin(list_volumes_response) -> <<"ListVolumesResponse">>; -msg_name_to_fqbin(create_volume_request) -> <<"CreateVolumeRequest">>; -msg_name_to_fqbin(update_volume_request) -> <<"UpdateVolumeRequest">>; -msg_name_to_fqbin(delete_volume_request) -> <<"DeleteVolumeRequest">>; -msg_name_to_fqbin(volume_attachment_identifier) -> <<"VolumeAttachmentIdentifier">>; -msg_name_to_fqbin(volume_attachment) -> <<"VolumeAttachment">>; -msg_name_to_fqbin(list_volume_attachments_request) -> <<"ListVolumeAttachmentsRequest">>; -msg_name_to_fqbin(list_volume_attachments_response) -> <<"ListVolumeAttachmentsResponse">>; -msg_name_to_fqbin(empty) -> <<"google.protobuf.Empty">>; -msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - --spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). - - --spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_package_name() -> 'google.protobuf'. - - -%% Whether or not the message names -%% are prepended with package name or not. -uses_packages() -> true. - - -source_basename() -> "volume.proto". - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned with extension, -%% see get_all_proto_names/0 for a version that returns -%% the basenames sans extension -get_all_source_basenames() -> ["volume.proto", "empty.proto"]. - - -%% Retrieve all proto file names, also imported ones. -%% The order is top-down. The first element is always the main -%% source file. The files are returned sans .proto extension, -%% to make it easier to use them with the various get_xyz_containment -%% functions. -get_all_proto_names() -> ["volume", "empty"]. - - -get_msg_containment("volume") -> - [create_volume_request, - delete_volume_request, - get_volume_request, - list_volume_attachments_request, - list_volume_attachments_response, - list_volumes_request, - list_volumes_response, - update_volume_request, - volume, - volume_attachment, - volume_attachment_identifier]; -get_msg_containment("empty") -> [empty]; -get_msg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_pkg_containment("volume") -> undefined; -get_pkg_containment("empty") -> 'google.protobuf'; -get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_service_containment("volume") -> ['VolumeService']; -get_service_containment("empty") -> []; -get_service_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_rpc_containment("volume") -> - [{'VolumeService', 'GetVolume'}, - {'VolumeService', 'ListVolumes'}, - {'VolumeService', 'CreateVolume'}, - {'VolumeService', 'UpdateVolume'}, - {'VolumeService', 'DeleteVolume'}, - {'VolumeService', 'ListVolumeAttachments'}, - {'VolumeService', 'GetVolumeAttachment'}, - {'VolumeService', 'AttachVolume'}, - {'VolumeService', 'DetachVolume'}]; -get_rpc_containment("empty") -> []; -get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_enum_containment("volume") -> []; -get_enum_containment("empty") -> []; -get_enum_containment(P) -> error({gpb_error, {badproto, P}}). - - -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachmentIdentifier">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"VolumeAttachment">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"UpdateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"GetVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"DeleteVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"CreateVolumeRequest">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"Volume">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumesResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"ListVolumeAttachmentsResponse">>) -> "volume"; -get_proto_by_msg_name_as_fqbin(<<"google.protobuf.Empty">>) -> "empty"; -get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). - - -get_proto_by_service_name_as_fqbin(<<"VolumeService">>) -> "volume"; -get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). - - --spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). - - -get_protos_by_pkg_name_as_fqbin(<<"google.protobuf">>) -> ["empty"]; -get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). - - - -gpb_version_as_string() -> - "4.19.8". - -gpb_version_as_list() -> - [4,19,8]. - -gpb_version_source() -> - "file". diff --git a/virtuerl/src/pb/volume_service_bhvr.erl b/virtuerl/src/pb/volume_service_bhvr.erl deleted file mode 100644 index 4fcf498..0000000 --- a/virtuerl/src/pb/volume_service_bhvr.erl +++ /dev/null @@ -1,45 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Behaviour to implement for grpc service VolumeService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(volume_service_bhvr). - -%% Unary RPC --callback get_volume(ctx:t(), controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volumes(ctx:t(), controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback create_volume(ctx:t(), controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback update_volume(ctx:t(), controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback delete_volume(ctx:t(), controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback attach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), ctx:t()} | grpcbox_stream:grpc_error_response(). - -%% Unary RPC --callback detach_volume(ctx:t(), controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). - diff --git a/virtuerl/src/pb/volume_service_client.erl b/virtuerl/src/pb/volume_service_client.erl deleted file mode 100644 index ad18a94..0000000 --- a/virtuerl/src/pb/volume_service_client.erl +++ /dev/null @@ -1,187 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc Client module for grpc service VolumeService. -%% @end -%%%------------------------------------------------------------------- - -%% this module was generated and should not be modified manually - --module(volume_service_client). - --compile(export_all). --compile(nowarn_export_all). - --include_lib("grpcbox/include/grpcbox.hrl"). - --define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). - --define(SERVICE, 'VolumeService'). --define(PROTO_MODULE, 'controller_pb'). --define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). --define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). --define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, - message_type=MessageType, - marshal_fun=?MARSHAL_FUN(Input), - unmarshal_fun=?UNMARSHAL_FUN(Output)}). - -%% @doc Unary RPC --spec get_volume(controller_pb:get_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Input) -> - get_volume(ctx:new(), Input, #{}). - --spec get_volume(ctx:t() | controller_pb:get_volume_request(), controller_pb:get_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume(Ctx, Input, #{}); -get_volume(Input, Options) -> - get_volume(ctx:new(), Input, Options). - --spec get_volume(ctx:t(), controller_pb:get_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/GetVolume">>, Input, ?DEF(get_volume_request, volume, <<"GetVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volumes(controller_pb:list_volumes_request()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Input) -> - list_volumes(ctx:new(), Input, #{}). - --spec list_volumes(ctx:t() | controller_pb:list_volumes_request(), controller_pb:list_volumes_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input) when ?is_ctx(Ctx) -> - list_volumes(Ctx, Input, #{}); -list_volumes(Input, Options) -> - list_volumes(ctx:new(), Input, Options). - --spec list_volumes(ctx:t(), controller_pb:list_volumes_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volumes_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volumes(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/ListVolumes">>, Input, ?DEF(list_volumes_request, list_volumes_response, <<"ListVolumesRequest">>), Options). - -%% @doc Unary RPC --spec create_volume(controller_pb:create_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Input) -> - create_volume(ctx:new(), Input, #{}). - --spec create_volume(ctx:t() | controller_pb:create_volume_request(), controller_pb:create_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input) when ?is_ctx(Ctx) -> - create_volume(Ctx, Input, #{}); -create_volume(Input, Options) -> - create_volume(ctx:new(), Input, Options). - --spec create_volume(ctx:t(), controller_pb:create_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -create_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/CreateVolume">>, Input, ?DEF(create_volume_request, volume, <<"CreateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec update_volume(controller_pb:update_volume_request()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Input) -> - update_volume(ctx:new(), Input, #{}). - --spec update_volume(ctx:t() | controller_pb:update_volume_request(), controller_pb:update_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input) when ?is_ctx(Ctx) -> - update_volume(Ctx, Input, #{}); -update_volume(Input, Options) -> - update_volume(ctx:new(), Input, Options). - --spec update_volume(ctx:t(), controller_pb:update_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:volume(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -update_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/UpdateVolume">>, Input, ?DEF(update_volume_request, volume, <<"UpdateVolumeRequest">>), Options). - -%% @doc Unary RPC --spec delete_volume(controller_pb:delete_volume_request()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Input) -> - delete_volume(ctx:new(), Input, #{}). - --spec delete_volume(ctx:t() | controller_pb:delete_volume_request(), controller_pb:delete_volume_request() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input) when ?is_ctx(Ctx) -> - delete_volume(Ctx, Input, #{}); -delete_volume(Input, Options) -> - delete_volume(ctx:new(), Input, Options). - --spec delete_volume(ctx:t(), controller_pb:delete_volume_request(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -delete_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/DeleteVolume">>, Input, ?DEF(delete_volume_request, empty, <<"DeleteVolumeRequest">>), Options). - -%% @doc Unary RPC --spec list_volume_attachments(controller_pb:list_volume_attachments_request()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Input) -> - list_volume_attachments(ctx:new(), Input, #{}). - --spec list_volume_attachments(ctx:t() | controller_pb:list_volume_attachments_request(), controller_pb:list_volume_attachments_request() | grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input) when ?is_ctx(Ctx) -> - list_volume_attachments(Ctx, Input, #{}); -list_volume_attachments(Input, Options) -> - list_volume_attachments(ctx:new(), Input, Options). - --spec list_volume_attachments(ctx:t(), controller_pb:list_volume_attachments_request(), grpcbox_client:options()) -> - {ok, controller_pb:list_volume_attachments_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -list_volume_attachments(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/ListVolumeAttachments">>, Input, ?DEF(list_volume_attachments_request, list_volume_attachments_response, <<"ListVolumeAttachmentsRequest">>), Options). - -%% @doc Unary RPC --spec get_volume_attachment(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Input) -> - get_volume_attachment(ctx:new(), Input, #{}). - --spec get_volume_attachment(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input) when ?is_ctx(Ctx) -> - get_volume_attachment(Ctx, Input, #{}); -get_volume_attachment(Input, Options) -> - get_volume_attachment(ctx:new(), Input, Options). - --spec get_volume_attachment(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -get_volume_attachment(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/GetVolumeAttachment">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec attach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Input) -> - attach_volume(ctx:new(), Input, #{}). - --spec attach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - attach_volume(Ctx, Input, #{}); -attach_volume(Input, Options) -> - attach_volume(ctx:new(), Input, Options). - --spec attach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:volume_attachment(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -attach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/AttachVolume">>, Input, ?DEF(volume_attachment_identifier, volume_attachment, <<"VolumeAttachmentIdentifier">>), Options). - -%% @doc Unary RPC --spec detach_volume(controller_pb:volume_attachment_identifier()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Input) -> - detach_volume(ctx:new(), Input, #{}). - --spec detach_volume(ctx:t() | controller_pb:volume_attachment_identifier(), controller_pb:volume_attachment_identifier() | grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input) when ?is_ctx(Ctx) -> - detach_volume(Ctx, Input, #{}); -detach_volume(Input, Options) -> - detach_volume(ctx:new(), Input, Options). - --spec detach_volume(ctx:t(), controller_pb:volume_attachment_identifier(), grpcbox_client:options()) -> - {ok, controller_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. -detach_volume(Ctx, Input, Options) -> - grpcbox_client:unary(Ctx, <<"/VolumeService/DetachVolume">>, Input, ?DEF(volume_attachment_identifier, empty, <<"VolumeAttachmentIdentifier">>), Options). - diff --git a/virtuerl/src/virtuerl.app.src b/virtuerl/src/virtuerl.app.src index 8d29911..ab60c7c 100644 --- a/virtuerl/src/virtuerl.app.src +++ b/virtuerl/src/virtuerl.app.src @@ -1,6 +1,6 @@ {application, virtuerl, [{description, "An OTP application"}, - {vsn, "0.1.0"}, + {vsn, git}, {registered, []}, {mod, {virtuerl_app, []}}, {applications, @@ -8,7 +8,6 @@ stdlib, inets, mochiweb, - cowboy, thoas, erlexec ]}, diff --git a/virtuerl/src/virtuerl_api_domain_col.erl b/virtuerl/src/virtuerl_api_domain_col.erl deleted file mode 100644 index 242a910..0000000 --- a/virtuerl/src/virtuerl_api_domain_col.erl +++ /dev/null @@ -1,58 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @author ilya -%%% @copyright (C) 2023, -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(virtuerl_api_domain_col). - --behaviour(cowboy_rest). - -%%-export([start_link/0]). --export([init/2, content_types_provided/2, to_text/2, allowed_methods/2, content_types_accepted/2, from_json/2]). - --define(SERVER, ?MODULE). - -%%%=================================================================== -%%% Spawning and gen_server implementation -%%%=================================================================== - -%%start_link() -> -%% Dispatch = cowboy_router:compile([ -%% {'_', [{"/", virtuerl_api, []}]} -%% ]), -%% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), -%% io:format("RESULT: ~p~n", [Res]), -%% Res. - -%% handler -%%init(Req0, State) -> -%% Req = cowboy_req:reply(200, #{<<"content-type">> => <<"text/plain">>}, <<"Hello elloh">>, Req0), -%% {ok, Req, State}. - -init(Req, State) -> - {cowboy_rest, Req, State}. - -allowed_methods(Req, State) -> - {[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>, <<"POST">>], Req, State}. - -content_types_accepted(Req, State) -> - {[{{<<"application">>, <<"json">>, '*'}, from_json}], - Req, State - }. - -from_json(Req, State) -> - {ok, RawJSON, Req1} = cowboy_req:read_body(Req), - {ok, JSON} = thoas:decode(RawJSON), - #{<<"networkID">> := NetworkID} = JSON, - Conf = #{network_id => NetworkID}, -%% virtuerl_mgt:create_vm(Conf), - {true, Req1, State}. - -content_types_provided(Req, State) -> - {[{{<<"text">>, <<"plain">>, '*'}, to_text}], - Req, State - }. - -to_text(Req, State) -> - {<<"OK">>, Req, State}. diff --git a/virtuerl/src/virtuerl_api_domain_res.erl b/virtuerl/src/virtuerl_api_domain_res.erl deleted file mode 100644 index a405e1f..0000000 --- a/virtuerl/src/virtuerl_api_domain_res.erl +++ /dev/null @@ -1,58 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @author ilya -%%% @copyright (C) 2023, -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(virtuerl_api_domain_res). - --behaviour(cowboy_handler). - -%%-export([start_link/0]). --export([init/2, content_types_provided/2, to_text/2, allowed_methods/2, content_types_accepted/2, from_json/2]). - --define(SERVER, ?MODULE). - -%%%=================================================================== -%%% Spawning and gen_server implementation -%%%=================================================================== - -%%start_link() -> -%% Dispatch = cowboy_router:compile([ -%% {'_', [{"/", virtuerl_api, []}]} -%% ]), -%% Res = cowboy:start_clear(my_listener, [{port, 8080}], #{env => #{dispatch => Dispatch}}), -%% io:format("RESULT: ~p~n", [Res]), -%% Res. - -%% handler -%%init(Req0, State) -> -%% Req = cowboy_req:reply(200, #{<<"content-type">> => <<"text/plain">>}, <<"Hello elloh">>, Req0), -%% {ok, Req, State}. - -init(Req, State) -> - {cowboy_rest, Req, State}. - -allowed_methods(Req, State) -> - {[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>, <<"POST">>], Req, State}. - -content_types_accepted(Req, State) -> - {[{{<<"application">>, <<"json">>, '*'}, from_json}], - Req, State - }. - -from_json(Req, State) -> - {ok, RawJSON, Req1} = cowboy_req:read_body(Req), - {ok, JSON} = thoas:decode(RawJSON), - #{<<"networkID">> := NetworkID} = JSON, - Conf = #{network_id => NetworkID}, -%% virtuerl_mgt:create_vm(Conf), - {true, Req1, State}. - -content_types_provided(Req, State) -> - {[{{<<"text">>, <<"plain">>, '*'}, to_text}], - Req, State - }. - -to_text(Req, State) -> - {<<"OK">>, Req, State}. From 672d3e01b80296dfba554e90fb0a0a699cf90d4e Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Wed, 20 Mar 2024 13:40:46 +0100 Subject: [PATCH 38/51] virtuerl: add GH action --- .github/workflows/virtuerl.yaml | 25 ++++++++++++++++++ virtuerl/hack/repack | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/virtuerl.yaml create mode 100755 virtuerl/hack/repack diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml new file mode 100644 index 0000000..3fe2ed2 --- /dev/null +++ b/.github/workflows/virtuerl.yaml @@ -0,0 +1,25 @@ +name: Build +on: + push: + branches-ignore: + - main +jobs: + virtuerl: + name: virtuerl + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: virtuerl + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install prerequisites + run: | + sudo apt update + sudo apt install rebar3 + - name: Create tar + run: | + rebar3 tar + find _build/ -name '*.tar.gz' -exec hack/repack {} \; diff --git a/virtuerl/hack/repack b/virtuerl/hack/repack new file mode 100755 index 0000000..c32c5a0 --- /dev/null +++ b/virtuerl/hack/repack @@ -0,0 +1,47 @@ +#!/bin/bash + +scratch=$(mktemp -d -t tmp.XXXXXXXXXX) +function finish { + rm -rf "$scratch" +} +trap finish EXIT + +pwd=$PWD +archive=$1 + +#list=( virtuerl/virtuerl*.tar.gz ) +#archive="${list[-1]}" + +tar xzf "$archive" --one-top-level="$scratch" +# list=( virtuerl/releases/*/ ) +# release="${list[-1]}" +# version="$(basename "$release")" +relvsndir=$(find $scratch/releases/* -type d) +version=$(basename $relvsndir) + +relnamepath=$(find $scratch/releases/ -maxdepth 1 -type f -name '*.rel') +relname=$(basename $relnamepath .rel) + +# cp -R virtuerl/{lib,erts*} "$scratch" +# mkdir -p "$scratch/releases" +# cp -R "virtuerl/releases/$version/" "$scratch/releases/$version" +# cp virtuerl/releases/{RELEASES,start_erl.data} "$scratch/releases/" +mv "$scratch/releases/$version/$relname.rel" "$scratch/releases/$version/$relname-$version.rel" +mv "$scratch/releases/$relname.rel" "$scratch/releases/$relname-$version.rel" + +# cp "$scratch/releases/$version/$relname-$version.rel" "$scratch/releases/$relname-$version.rel" + +# cp -R virtuerl/* "$scratch" +cd "$scratch" +# tree -I lib +# exit + + +mkdir -p bin/ +rm bin/* +find erts* ! -name 'start_erl' ! -name 'erlexec' ! -name 'beam.smp' ! -name 'epmd' ! -name 'inet_gethost' ! -name 'erl_child_setup' ! -name 'heart' -type f -exec rm {} + +find releases -type f \( -name 'vm.args' -o -name 'start_clean.boot' -o -name 'no_dot_erlang.boot' \) -exec rm {} + +cp erts*/bin/start_erl bin/start_erl +tree -I lib + +tar czf "$pwd/$relname-$version.tar.gz" * From 42c5e3ba77a671d81fbec767701eb71bb06b1d79 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 1 Jun 2024 22:00:10 +0200 Subject: [PATCH 39/51] virtuerl: big move towards first MVP --- virtuerl/.gitignore | 1 + virtuerl/README.md | 41 ++- virtuerl/rebar.config | 12 + virtuerl/src/virtuerl_app.erl | 1 + virtuerl/src/virtuerl_ghac.erl | 217 +++++++++++++ virtuerl/src/virtuerl_img.erl | 82 +++++ virtuerl/src/virtuerl_ipam.erl | 1 + virtuerl/src/virtuerl_mgt.erl | 122 +++++-- virtuerl/src/virtuerl_net.erl | 98 +++++- virtuerl/src/virtuerl_qemu.erl | 526 ++++++++++++++++++++++++++++++- virtuerl/src/virtuerl_stor.erl | 48 --- virtuerl/src/virtuerl_sup.erl | 7 + virtuerl/src/virtuerl_ui.erl | 134 ++++++-- virtuerl/src/virtuerl_util.erl | 10 +- virtuerl/src/virtuerl_vnc.erl | 28 -- virtuerl/test/virtuerl_SUITE.erl | 118 ++++++- virtuerl/virtuerl.iml | 22 -- 17 files changed, 1275 insertions(+), 193 deletions(-) create mode 100644 virtuerl/src/virtuerl_ghac.erl create mode 100644 virtuerl/src/virtuerl_img.erl delete mode 100644 virtuerl/src/virtuerl_stor.erl delete mode 100644 virtuerl/virtuerl.iml diff --git a/virtuerl/.gitignore b/virtuerl/.gitignore index 210b641..78647f9 100644 --- a/virtuerl/.gitignore +++ b/virtuerl/.gitignore @@ -1,3 +1,4 @@ +*.iml .DS_Store .vagrant/ khepri*/ diff --git a/virtuerl/README.md b/virtuerl/README.md index 91edc5e..8f86b0e 100644 --- a/virtuerl/README.md +++ b/virtuerl/README.md @@ -3,16 +3,46 @@ virtuerl An OTP application -Build ------ +# Required packages +```sh +sudo apt install ovmf swtpm +``` - $ rebar3 compile +# Windows Guests +## Disable boot prompt +```sh +sudo mount -o loop Win11_23H2_EnglishInternational_x64v2.iso /mnt/win + +genisoimage \ + --allow-limited-size \ + -no-emul-boot \ + -b "boot/etfsboot.com" \ + -boot-load-seg 0 \ + -boot-load-size 8 \ + -eltorito-alt-boot \ + -no-emul-boot \ + -e "efi/microsoft/boot/efisys_noprompt.bin" \ + -boot-load-size 1 \ + -iso-level 4 \ + -udf \ + -o "win.iso" \ + /mnt/win/ +``` -## Running +# Running On the server +Make sure IP forwarding is enabled (`/etc/sysctl.conf`) +``` +# Uncomment the next line to enable packet forwarding for IPv4 +net.ipv4.ip_forward=1 +# Uncomment the next line to enable packet forwarding for IPv6 +net.ipv6.conf.all.forwarding=1 +``` +Run `sysctl -w` to commit changes. + ```sh sudo -s ./erts-13.1.5/bin/erl -mode embedded -boot releases/0.7.0+build.61.ref8fc0b7e/start -config releases/0.7.0+build.61.ref8fc0b7e/sys.config -proto_dist inet6_tcp -name verbit@verbit.in-berlin.de -setcookie abcdef ``` @@ -21,4 +51,7 @@ Locally ```sh rebar3 compile erl -name moi -proto_dist inet6_tcp -setcookie abcdef -pa _build/default/lib/*/ebin -hidden +(moi@t460s.lan)1> net_adm:ping('virtuerl@a.in6.dev'). +pong +(moi@t460s.lan)2> virtuerl_ui:start('virtuerl@a.in6.dev'). ``` diff --git a/virtuerl/rebar.config b/virtuerl/rebar.config index 94af93d..d87276d 100644 --- a/virtuerl/rebar.config +++ b/virtuerl/rebar.config @@ -16,3 +16,15 @@ {config, "config/sys.config"}, {apps, [virtuerl]} ]}. + +{ct_opts, [ + {sys_config, "config/sys.config"} +]}. + +{project_plugins, [ + {eqwalizer_rebar3, + {git_subdir, + "https://github.com/whatsapp/eqwalizer.git", + {branch, "main"}, + "eqwalizer_rebar3"}} +]}. diff --git a/virtuerl/src/virtuerl_app.erl b/virtuerl/src/virtuerl_app.erl index 6a3d662..361e003 100644 --- a/virtuerl/src/virtuerl_app.erl +++ b/virtuerl/src/virtuerl_app.erl @@ -20,6 +20,7 @@ start(_StartType, _StartArgs) -> %% io:format("RESULT: ~p~n", [Res]), %% {ok, _} = Res, %% exec:debug(4), + httpc:set_options([{ipfamily, inet6fb4}]), virtuerl_sup:start_link(). start() -> diff --git a/virtuerl/src/virtuerl_ghac.erl b/virtuerl/src/virtuerl_ghac.erl new file mode 100644 index 0000000..d1b00bd --- /dev/null +++ b/virtuerl/src/virtuerl_ghac.erl @@ -0,0 +1,217 @@ +-module(virtuerl_ghac). + +-export([handle_continue/2]). + +-export([list_domains/0]). + +-export([list_runners/0]). + +-behaviour(gen_server). + +-export([pending_jobs/0]). + +-export([start/0, start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). + +-define(SERVER, ?MODULE). + % owner="verbit", + % repo="restvirt", + % token="230b9671f90e4ff0f1f722776a6ef7e4620d97d0", + +-define(HEADERS, [{"User-Agent", "terstegen"}, {"Authorization", "Bearer 230b9671f90e4ff0f1f722776a6ef7e4620d97d0"}]). +-define(BASE_URL, "https://api.github.com/repos/verbit/restvirt"). + +pending_jobs() -> + {ok, {{_, 200, _}, _Headers, RunsRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runs?status=queued"], ?HEADERS}, [], []), + {ok, RunsJson} = thoas:decode(RunsRaw), + #{<<"workflow_runs">> := WorkflowRuns} = RunsJson, + RunIds = [RunId || #{<<"id">> := RunId} = Run <- WorkflowRuns], + Jobs = lists:map(fun list_jobs/1, RunIds), + NumJobs = lists:foldl(fun (#{<<"total_count">> := Count}, Acc) -> Acc + Count end, 0, Jobs), + NumJobs. + +list_jobs(RunId) -> + {ok, {{_, 200, _}, _Headers, JobsRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runs/", RunId, "/jobs"], ?HEADERS}, [], []), + {ok, JobsJson} = thoas:decode(JobsRaw), + JobsJson. + +list_runners() -> + {ok, {{_, 200, _}, _Headers, RunnersRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runners"], ?HEADERS}, [], []), + {ok, RunnersJson} = thoas:decode(RunnersRaw), + #{<<"runners">> := Runners} = RunnersJson, + [Runner || #{<<"status">> := Status} = Runner <- Runners, Status == <<"online">>]. + +list_domains() -> + Domains = virtuerl_mgt:domains_list(), + [Domain || #{name := Name} = Domain <- Domains, + string:prefix(Name, "actions-") /= nomatch, + string:prefix(Name, "actions-base") == nomatch]. + +create_runner(NetId) -> + {ok, {{_, 201, _}, _Headers, TokenRaw}} = httpc:request(post, {[?BASE_URL, "/actions/runners/registration-token"], ?HEADERS, "application/json", ""}, [], []), + {ok, #{<<"token">> := Token}} = thoas:decode(TokenRaw), + + {ok, _} = virtuerl_mgt:domain_create(#{ + network_id => NetId, + name => io_lib:format("actions-~s", [virtuerl_util:uuid4()]), + vcpu => 2, + memory => 8192, + base_image => "actions-base.qcow2", + user_data => [ +"#cloud-config\n", +"\n", +"users:\n", +" - default\n", +" - name: ilya\n", +" shell: /bin/bash\n", +" sudo: ALL=(ALL) NOPASSWD:ALL\n", +" ssh_authorized_keys:\n", +" - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCKxHNpVg1whPegPv0KcRQTOfyVIqLwvMfVLyT9OpBPXHDudsFz9soOgMUEyWm8ZJ+pJ9fRCg66B+D5/ZRTwJCBpyNncfXCwu8xEJgEeoIubObh6t6dHWqqxX/yhHAS5GIRUSypm78qg6V+SQ6SeJXSjOCLAbZmhyWgJrlDm9M6GTPQhPAztrgsCUrzxIpZ5el5BwJXrm3I+LOmofAUqgbLQz9HuGJzPpnfABDa9WoVfI0L7oTr0qGpWwx8l71b2s8AYl7GMD/bEkZKyi9SSwEVCHA88F7dYYrZ3+fMXE/mJf+v0ece2lIDT7Te1gtqiLu/izJNmqD+b6mtnnXxVxNOtynhv3t6uLE9kBX22SBCCRqPJzETGNXvYH6fATEe88dhLh8kTppLRB5UGUd/zztxuNBSpMwFXaq8SlTKURxvF8BuFIPCz0FW8fq+TA/xZfBYsiVt59jXgl6BQyEGY4bMuMtT2nD8QXwZ5vsj52mzKGJwBwduiaX302brHYUyQkuyLII5iqmCNZ5YLlMY76a61Yg9pWMeRwQscSO2k4a18GOo+sIrQVTyUQiT3KhRRaDNrZuCPicQRgkJuiS1fKt1cWjnOlyweLxSYbpKnoS0H7vt+NrtbU1u9FPknXQPQ0pxixPpV3zgUdfOLmisFH7WGVjwNVvZAlNc5uyqm0fbw== ilya@verbit.io\n", +"\n", +"runcmd:\n", +" - cd /opt/actions-runner && RUNNER_ALLOW_RUNASROOT=1 ./config.sh --unattended --url https://github.com/verbit/restvirt --token ", Token, " --ephemeral\n", +" - cd /opt/actions-runner && ./svc.sh install\n", +" - cd /opt/actions-runner && ./svc.sh start\n" + ] + }). + +sync_runners(NetId, DomainList, RunnerList) -> + io:format("Syncing...~nDomains: ~p~nRunners: ~p~n", [DomainList, RunnerList]), + + Domains = maps:from_list([{DomId, Domain} || #{id := DomId} = Domain <- DomainList]), + Runners = maps:from_list([{Name, Runner} || #{<<"name">> := Name} = Runner <- RunnerList]), + + Now = erlang:system_time(millisecond), + + ToDeleteIds = [DomId || #{id := DomId, name := Name, created_at := CreatedAt} = _Domain <- DomainList, + Now - CreatedAt > 5*60*1000, + not maps:is_key(iolist_to_binary(Name), Runners)], + [virtuerl_mgt:domain_delete(#{id => DomId}) || DomId <- ToDeleteIds], + + RemDomains = maps:without(ToDeleteIds, Domains), + + RequiredRunners = max(0, pending_jobs() + 2 - maps:size(RemDomains)), + io:format("Required new runners: ~p~n", [RequiredRunners]), + [create_runner(NetId) || _ <- lists:seq(1, RequiredRunners)], + + ok. + +start() -> + gen_server:start({local, ?SERVER}, ?MODULE, [], []). + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + {ok, Nets} = virtuerl_ipam:ipam_list_nets(), + Filtered = maps:filter(fun (NetId, NetConf) -> + Cidrs = [lists:flatten(io_lib:format("~s/~B", [Addr, Prefixlen])) || #{address := Addr, prefixlen := Prefixlen} <- maps:values(maps:with([cidr4, cidr6], NetConf))], + Res = lists:sort(Cidrs) == lists:sort(["192.168.24.0/24", "fdbe:3c6a:3aef::/48"]), + Res + end, Nets), + + {ok, NetId} = case maps:keys(Filtered) of + [Res] -> {ok, Res}; + [] -> + io:format("ghac: creating network for actions worker~n"), + {ok, Id} = virtuerl_ipam:ipam_create_net([{<<192:8,168:8,24:8,0:8>>, 24}, {<<16#fdbe:16, 16#3c6a:16, 16#3aef:16, 0:80>>, 48}]), + {ok, Id}; + _ -> error + end, + + self() ! sync, + {ok, {NetId}, {continue, ensure_base}}. + +wait_for_domain_shutdown(DomId, Timeout) -> + timer:sleep(2000), + Deadline = erlang:system_time(millisecond) + Timeout, + do_wait_for_domain_shutdown(DomId, Deadline). + +do_wait_for_domain_shutdown(DomId, Deadline) -> + case virtuerl_mgt:domain_get(#{id => DomId}) of + {ok, #{state := stopped}} -> ok; + {error, Error} -> {error, Error}; + _ -> + case erlang:system_time(millisecond) > Deadline of + true -> + {error, timeout}; + false -> + timer:sleep(2000), + do_wait_for_domain_shutdown(DomId, Deadline) + end + end. + +handle_continue(ensure_base, {NetId} = State) -> + ok = case lists:filter(fun (ImgName) -> string:equal(ImgName, "actions-base.qcow2") end, virtuerl_img:list_images()) of + [_ImgFound] -> ok; + [] -> + io:format("ghac: creating base image domain~n"), + % create image + {ok, #{id := DomId}} = virtuerl_mgt:domain_create(#{ + network_id => NetId, + name => "actions-base", + vcpu => 2, + memory => 8192, + base_image => "debian-12-genericcloud-amd64-20240507-1740.qcow2", + user_data => [ +"#cloud-config\n", +"\n", +% "# apt_get_command: ["apt-get", "--option=Dpkg::Options::=--force-confold", "--option=Dpkg::options::=--force-unsafe-io", "--assume-yes", "--quiet", "--no-install-recommends"]\n", +"package_upgrade: true\n", +"# packages:\n", +"# - libvirt-daemon-system\n", +"# - libvirt-dev\n", +"# - qemu-kvm\n", +"# - qemu-utils\n", +"# - dnsmasq-base\n", + +"runcmd:\n", +" - apt install -y gcc g++ pkg-config\n", +" - apt install -y --no-install-recommends rebar3 qemu-kvm qemu-utils dnsmasq-base gcc\n", +" - mkdir -p /opt/actions-runner\n", +" - curl -O -L https://github.com/actions/runner/releases/download/v2.316.1/actions-runner-linux-x64-2.316.1.tar.gz\n", +" - tar xzf ./actions-runner-linux-x64-2.316.1.tar.gz -C /opt/actions-runner\n", +" - rm ./actions-runner-linux-x64-2.316.1.tar.gz\n", + +"apt:\n", +" primary:\n", +" - arches: [default]\n", +" search:\n", +" - http://mirror.ipb.de/debian/\n", +" - http://security.debian.org/debian-security\n", + +"power_state:\n", +" mode: poweroff\n", +" condition: test -d /opt/actions-runner\n" + ] + }), + + ok = wait_for_domain_shutdown(DomId, 10*60*1000), % 10 minutes + virtuerl_mgt:image_from_domain(DomId, "actions-base"), + virtuerl_mgt:domain_delete(#{id => DomId}), + + ok; + _ -> error + end, + + {noreply, State}. + +handle_call(_Req, _From, State) -> + {reply, ok, State}. + +handle_cast(_Request, State) -> + {noreply, State}. + +handle_info(sync, {NetId} = State) -> + DomainList = list_domains(), + RunnerList = list_runners(), + sync_runners(NetId, DomainList, RunnerList), + erlang:send_after(30*1000, self(), sync), + {noreply, State}. + +terminate(_Reason, State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. diff --git a/virtuerl/src/virtuerl_img.erl b/virtuerl/src/virtuerl_img.erl new file mode 100644 index 0000000..9c5719d --- /dev/null +++ b/virtuerl/src/virtuerl_img.erl @@ -0,0 +1,82 @@ +%%%------------------------------------------------------------------- +%%% @author ilya +%%% @copyright (C) 2023, +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(virtuerl_img). + +-export([list_images/0]). + +-behaviour(gen_server). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). +-export([ensure_image/1]). + +-define(SERVER, ?MODULE). +-define(APPLICATION, virtuerl). + +%%%=================================================================== +%%% Spawning and gen_server implementation +%%%=================================================================== + +list_images() -> + gen_server:call(?SERVER, list_images). + +ensure_image(ImageName) -> + gen_server:call(?SERVER, {ensure_image, ImageName}, infinity). + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +init([]) -> + {ok, []}. + +handle_call(list_images, _Sender, State) -> + {ok, Filenames} = file:list_dir(virtuerl_mgt:home_path()), + Images = [Filename || Filename <- Filenames, virtuerl_util:ends_with(Filename, ".qcow2")], + Result = lists:uniq(["debian-12-genericcloud-amd64-20240507-1740.qcow2" | Images]), + {reply, Result, State}; + +handle_call({ensure_image, ImageName}, _Sender, State) -> + io:format("DOWNLOADING..."), + Path = filename:join(virtuerl_mgt:home_path(), ImageName), + Res = case filelib:is_regular(Path) of + true -> {ok, Path}; + false -> + {ok, Pat} = re:compile("^debian-12-genericcloud-amd64-(\\d+-\\d+).qcow2$"), + case re:run(ImageName, Pat, [{capture, all_but_first, list}]) of + {match, [Build]} -> + CacheImagePath = filename:join(["/tmp/virtuerl/cache", ImageName]), + case filelib:is_regular(CacheImagePath) of + true -> + file:copy(CacheImagePath, Path), + {ok, Path}; + false -> + TempImagePath = filename:join(["/tmp/virtuerl/", ImageName]), + ok = filelib:ensure_dir(CacheImagePath), + {ok, _} = httpc:request(get, {["https://cloud.debian.org/images/cloud/bookworm/", Build, "/", ImageName], []}, [], + [{stream, TempImagePath}]), + file:rename(TempImagePath, CacheImagePath), + file:copy(CacheImagePath, Path), + {ok, Path} + end; + nomatch -> + {error, not_supported} + end + end, + {reply, Res, State}. + +handle_cast(_Req, State) -> + {noreply, State}. + +handle_info(_Req, State) -> + {noreply, State}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. diff --git a/virtuerl/src/virtuerl_ipam.erl b/virtuerl/src/virtuerl_ipam.erl index b332565..b31cec0 100644 --- a/virtuerl/src/virtuerl_ipam.erl +++ b/virtuerl/src/virtuerl_ipam.erl @@ -36,6 +36,7 @@ req(Msg) -> -record(network, {last_insert, from, to, address, prefixlen}). +-spec ipam_create_net([{binary(), integer()}]) -> {ok, binary()}. ipam_create_net(NetworkDef) -> ID = virtuerl_util:uuid4(), ipam_put_net({ID, NetworkDef}). diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index c58b84b..f2b085e 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -6,6 +6,10 @@ %%%------------------------------------------------------------------- -module(virtuerl_mgt). +-export([image_from_domain/2]). + +-export([domain_update/1]). + -behaviour(gen_server). -export([start_link/0]). @@ -22,10 +26,10 @@ create_vm() -> %%create_vm(#{cpus := NumCPUs, memory := Memory}) -> domain_create(Conf) -> - gen_server:call(?SERVER, {domain_create, Conf}). + gen_server:call(?SERVER, {domain_create, Conf}, infinity). domain_delete(Conf) -> - gen_server:call(?SERVER, {domain_delete, Conf}). + gen_server:call(?SERVER, {domain_delete, Conf}, infinity). domain_get(Conf) -> gen_server:call(?SERVER, {domain_get, Conf}). @@ -34,12 +38,18 @@ domain_get(Conf) -> domains_list() -> gen_server:call(?SERVER, domains_list). +domain_update(Conf) -> + gen_server:call(?SERVER, {domain_update, Conf}). + domain_stop(Id) -> gen_server:call(?SERVER, {domain_update, #{id => Id, state => stopped}}). domain_start(Id) -> gen_server:call(?SERVER, {domain_update, #{id => Id, state => running}}). +image_from_domain(DomainId, ImageName) -> + gen_server:call(?SERVER, {image_from_domain, #{id => DomainId, image_name => ImageName}}, infinity). + %%%=================================================================== %%% Spawning and gen_server implementation @@ -60,19 +70,6 @@ init([]) -> handle_continue(setup_base, State) -> ok = filelib:ensure_path(filename:join(home_path(), "domains")), - - BaseImagePath = filename:join(home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"), -%% BaseImagePath = filename:join(home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"), - case filelib:is_regular(BaseImagePath) of - true -> ok; - false -> - TempImagePath = "/tmp/virtuerl/debian-12-genericcloud-amd64-20230910-1499.qcow2", - ok = filelib:ensure_dir(TempImagePath), - {ok, _} = httpc:request(get, {"https://cloud.debian.org/images/cloud/bookworm/20230910-1499/debian-12-genericcloud-amd64-20230910-1499.qcow2", []}, [], - [{stream, TempImagePath}]), - file:rename(TempImagePath, BaseImagePath) - end, - {noreply, State, {continue, sync_domains}}; @@ -87,7 +84,7 @@ handle_continue(sync_domains, {Table} = State) -> ToAdd = sets:subtract(TargetDomains, RunningDomains), [supervisor:terminate_child(virtuerl_sup, Id) || Id <- sets:to_list(ToDelete)], [supervisor:delete_child(virtuerl_sup, Id) || Id <- sets:to_list(ToDelete)], - ok = gen_server:call(virtuerl_net, {net_update}), + ok = gen_server:call(virtuerl_net, {net_update}, infinity), [ supervisor:start_child(virtuerl_sup, { Id, {virtuerl_qemu, start_link, [Id]}, @@ -111,7 +108,14 @@ generate_unique_tap_name(TapNames) -> handle_call({domain_create, Conf}, _From, State) -> {Table} = State, DomainID = virtuerl_util:uuid4(), - Domain = maps:merge(#{id => DomainID, name => DomainID, vcpu => 1, memory => 512}, Conf), % TODO: save ipv4 addr as well + Domain0 = maps:merge(#{id => DomainID, name => DomainID, vcpu => 4, memory => 4096, + os_type => "linux", created_at => erlang:system_time(millisecond)}, Conf), % TODO: save ipv4/6 addr as well + Domain = case Domain0 of + #{os_type := "linux"} -> + maps:merge(#{base_image => "debian-12-genericcloud-amd64-20240211-1654.qcow2"}, Domain0); + #{os_type := "windows"} -> + maps:merge(#{setup_iso => "Win11_23H2_EnglishInternational_x64v2_noprompt.iso"}, Domain0) + end, dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), @@ -156,7 +160,14 @@ handle_call({domain_create, Conf}, _From, State) -> <> = <<(rand:uniform(16#ffffffffffff)):48>>, MacAddr = <>, - dets:insert(Table, {DomainID, Domain#{network_addrs => Cidrs, mac_addr=>MacAddr, ipv4_addr=>Ipv4Addr, ipv6_addr => Ipv6Addr, cidrs => IpCidrs, tap_name => TapName}}), + dets:insert(Table, {DomainID, + Domain#{ + network_addrs => Cidrs, + mac_addr=>MacAddr, + ipv4_addr=>Ipv4Addr, + ipv6_addr => Ipv6Addr, + cidrs => IpCidrs, + tap_name => TapName}}), dets:sync(Table), ok = gen_server:call(virtuerl_net, {net_update}), @@ -164,16 +175,20 @@ handle_call({domain_create, Conf}, _From, State) -> supervisor:start_child(virtuerl_sup, { DomainID, {virtuerl_qemu, start_link, [DomainID]}, - permanent, + transient, infinity, worker, [] }), - {reply, {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName), mac_addr => binary:encode_hex(MacAddr)}, maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, State}; -handle_call({domain_update, #{id := DomainID, state := RunState}}, _From, {Table} = State) -> + {reply, + {ok, maps:merge(#{id => DomainID, tap_name => iolist_to_binary(TapName), mac_addr => binary:encode_hex(MacAddr)}, + maps:map(fun(_, V) -> iolist_to_binary(virtuerl_net:format_ip(V)) end, AddressesMap))}, + State}; +handle_call({domain_update, #{id := DomainID} = DomainUpdate0}, _From, {Table} = State) -> + DomainUpdate = maps:remove(id, DomainUpdate0), Reply = case dets:lookup(Table, DomainID) of [{_, Domain}] -> - ok = dets:insert(Table, {DomainID, Domain#{state => RunState}}), + ok = dets:insert(Table, {DomainID, maps:merge(Domain, DomainUpdate)}), ok = dets:sync(Table), ok; [] -> notfound @@ -187,24 +202,63 @@ handle_call({domain_get, #{id := DomainID}}, _From, State) -> {Table} = State, Reply = case dets:lookup(Table, DomainID) of [{_, #{mac_addr := MacAddr, ipv4_addr:=IP, tap_name := TapName} = Domain}] -> - DomRet = Domain#{mac_addr := binary:encode_hex(MacAddr), ipv4_addr := virtuerl_net:format_ip_bitstring(IP), tap_name := iolist_to_binary(TapName)}, + DomRet = Domain#{ + mac_addr := binary:encode_hex(MacAddr), + ipv4_addr := virtuerl_net:format_ip_bitstring(IP), + tap_name := iolist_to_binary(TapName)}, {ok, maps:merge(#{state => running, name => DomainID, vcpu => 1, memory => 512}, DomRet)}; [] -> notfound end, {reply, Reply, State}; handle_call({domain_delete, #{id := DomainID}}, _From, State) -> {Table} = State, - ok = virtuerl_ipam:unassign(DomainID), - Res = dets:delete(Table, DomainID), - dets:sync(Table), - io:format("terminating ~p~n", [DomainID]), - supervisor:terminate_child(virtuerl_sup, DomainID), - io:format("done terminating ~p~n", [DomainID]), - supervisor:delete_child(virtuerl_sup, DomainID), - DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), - file:del_dir_r(DomainHomePath), - ok = gen_server:call(virtuerl_net, {net_update}), - {reply, Res, State}. + Res = case dets:lookup(Table, DomainID) of + [] -> {error, notfound}; + [{_, Domain}] -> + dets:insert(Table, {DomainID, Domain#{state => deleting}}), + dets:sync(Table), + spawn_link(fun () -> + io:format("terminating ~p~n", [DomainID]), + supervisor:terminate_child(virtuerl_sup, DomainID), + io:format("done terminating ~p~n", [DomainID]), + supervisor:delete_child(virtuerl_sup, DomainID), + DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), + file:del_dir_r(DomainHomePath), + ok = virtuerl_ipam:unassign(DomainID), + ok = gen_server:call(virtuerl_net, {net_update}), + dets:delete(Table, DomainID), + virtuerl_pubsub:send({domain_deleted, DomainID}) + end), + ok + end, + {reply, Res, State}; +handle_call({image_from_domain, #{id := DomainID, image_name := ImageName}}, _From, {Table} = State) -> + case dets:lookup(Table, DomainID) of + [] -> gen_server:reply(_From, {error, notfound}); + [{_, Domain}] -> + spawn(fun() -> + #{state := DomState} = Domain, + case DomState of + running -> domain_stop(DomainID); + _ -> ok + end, + + ImgPath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID, "root.qcow2"]), + ImgName = string:concat(ImageName, ".qcow2"), + DestPath = filename:join(["/tmp/virtuerl", ImgName]), + ok = filelib:ensure_dir(DestPath), + {ok, _} = file:copy(ImgPath, DestPath), + ok = file:rename(DestPath, filename:join([virtuerl_mgt:home_path(), ImgName])), + + case DomState of + running -> domain_start(DomainID); + _ -> ok + end, + + gen_server:reply(_From, ok) + end) + end, + {noreply, State}. handle_cast(_Request, State) -> {noreply, State}. diff --git a/virtuerl/src/virtuerl_net.erl b/virtuerl/src/virtuerl_net.erl index 6031ad4..f3be7e9 100644 --- a/virtuerl/src/virtuerl_net.erl +++ b/virtuerl/src/virtuerl_net.erl @@ -6,6 +6,12 @@ %%%------------------------------------------------------------------- -module(virtuerl_net). +-export([update_net/0]). + +-export([format_cidr/1]). + +-export([normalize_net/1]). + -behaviour(gen_server). -include_lib("kernel/include/logger.hrl"). @@ -24,6 +30,9 @@ start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). +update_net() -> + gen_server:call(?SERVER, {net_update}). + init([]) -> ?LOG_INFO(#{what => "Started", who => virtuerl_net}), {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), @@ -69,8 +78,6 @@ update_net(Table) -> %% append VM.IP to static routes: VM.IP via $VM.network.bridge % 2. birdc configure % 3. profit? - Domains = dets:match_object(Table, '_'), - [io:format("~p~n", [Domain]) || Domain <- Domains], reload_net(Table). handle_interface(If, Table) -> @@ -94,14 +101,14 @@ get_cidrs(If) -> reload_net(Table) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), - io:format("~p~n", [JSON]), + % io:format("~p~n", [JSON]), Matched = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), %% lists:foreach(fun(L) -> handle_interface(L, Table) end, Matched), - io:format("Actual: ~p~n", [Matched]), + % io:format("Actual: ~p~n", [Matched]), Domains = dets:match_object(Table, '_'), TargetAddrs = sets:from_list([lists:sort(network_cidrs_to_bride_cidrs(Cidrs)) || {_, #{network_addrs := Cidrs}} <- Domains]), - io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), + % io:format("Target: ~p~n", [sets:to_list(TargetAddrs)]), update_nftables(Domains), sync_networks(Matched, TargetAddrs), sync_taps(Domains), @@ -127,9 +134,57 @@ update_nftables(Domains) -> end || {Family, Addr} <- BridgeAddrsTyped, Prot <- ["tcp", "udp"]], + + ToRule = fun (#{protocols := Protos, target_ports := Ports}, Cidrs) -> + ProtosStr = string:join(Protos, ","), + Ports0 = [ + case Port of + Num when is_integer(Num) -> + integer_to_list(Num); + Str when is_list(Str) orelse is_binary(Str) -> + Str + end + || Port <- Ports], % FIXME: validate ports? + PortsStr = ["{", string:join(Ports0, ","), "}"], + + TagIp = fun ({Ip, _}) -> + Tag = case bit_size(Ip) of + 32 -> + "ip"; + 128 -> + "ip6" + end, + {Tag, Ip} + end, + TaggedIps = lists:map(TagIp, Cidrs), + + [[" meta l4proto {", ProtosStr, "} ", Tag, " daddr ", virtuerl_net:format_ip(Ip), " th dport ", PortsStr, " accept\n"] + || {Tag, Ip} <- TaggedIps] + end, + ForwardRules = [ToRule(InboundRule, Cidrs) || {_Id, #{cidrs := Cidrs, inbound_rules := InboundRules0}} <- Domains, InboundRule <- InboundRules0], + % lists:flatten(List), + IoList = [ "table inet virtuerl\ndelete table inet virtuerl\n\n", "table inet virtuerl {\n", + " chain input {\n", + " type filter hook input priority filter; policy accept;\n", + " ct state established,related accept\n", + ForwardRules, + " oifname \"verlbr*\" reject\n", + " }\n", + "\n", + " chain forward {\n", + " type filter hook forward priority filter; policy accept;\n", + " iifname \"verlbr*\" accept\n", + " ct state established,related accept\n", + ForwardRules, + " oifname \"verlbr*\" reject\n", + " }\n", + "\n", + "\n", + "\n", + "\n", " chain output {\n", " type nat hook output priority -105; policy accept;\n", DnsRules, @@ -142,11 +197,12 @@ update_nftables(Domains) -> " chain postrouting {\n", " type nat hook postrouting priority -5; policy accept;\n", - " oifname != \"verlbr*\" iifname \"verlbr*\" masquerade\n", % TODO: we need to base it on IPs + " iifname \"verlbr*\" ip saddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 } ip daddr != { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 } masquerade\n", + " iifname \"verlbr*\" ip6 saddr fc00::/7 ip6 daddr != fc00::/7 masquerade\n", " }\n", "}\n" ], - io:format("~s~n", [IoList]), + % io:format("~s~n", [IoList]), Path = iolist_to_binary(["/tmp/virtuerl/", "nftables_", virtuerl_util:uuid4(), ".conf"]), ok = filelib:ensure_dir(Path), @@ -179,6 +235,10 @@ bridge_addr(<>, Prefixlen) -> <> = Addr, <>. +normalize_net({<>, Prefixlen}) -> + <> = Addr, + {<>, Prefixlen}. + parse_cidr(<>) -> parse_cidr(binary_to_list(CIDR)); parse_cidr(CIDR) -> [IP, Prefixlen] = string:split(CIDR, "/", trailing), @@ -200,6 +260,9 @@ format_ip(<>) -> format_ip_bitstring(IP) -> list_to_binary(format_ip(IP)). +format_cidr({<>, Prefixlen}) -> + io_lib:format("~s/~B", [format_ip(Addr), Prefixlen]). + format_bird_route(<>) -> io_lib:format("~s/~B", [format_ip(IP), bit_size(IP)]). @@ -212,11 +275,12 @@ update_bird_conf(Domains) -> Output = os:cmd("ip -j addr"), {ok, JSON} = thoas:decode(Output), Bridges = maps:from_list([get_cidrs(L) || L <- JSON, startswith(maps:get(<<"ifname">>, L), <<"verlbr">>)]), - AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} || {_, #{network_addrs := {NetAddr, Prefixlen}, ipv4_addr := Addr}} <- Domains]), + AddrMap = maps:from_list([{Addr, {bridge_addr(NetAddr), Prefixlen}} + || {_, #{network_addrs := {NetAddr, Prefixlen}, ipv4_addr := Addr}} <- Domains]), AddrToBridgeMap = maps:map(fun (_, Net) -> maps:get(Net, Bridges) end, AddrMap), - io:format("DOMAINS: ~p~n", [Domains]), - io:format("AddrToBridgeMap: ~p~n", [AddrToBridgeMap]), + % io:format("DOMAINS: ~p~n", [Domains]), + % io:format("AddrToBridgeMap: ~p~n", [AddrToBridgeMap]), file:write_file("birderl.conf", lists:join("\n", ["protocol static {", " ipv4;"] ++ build_routes(AddrToBridgeMap) ++ ["}\n"] )), reload_bird(Domains). @@ -269,13 +333,14 @@ sync_taps(Domains) -> OutputTaps = os:cmd("ip -j link"), {ok, JSONTaps} = thoas:decode(OutputTaps), - io:format("TAPS: ~p~n", [JSONTaps]), + % io:format("TAPS: ~p~n", [JSONTaps]), TapsActual = sets:from_list([maps:get(<<"ifname">>, L) || L <- JSONTaps, startswith(maps:get(<<"ifname">>, L), <<"verltap">>)]), TapsTarget = sets:from_list([iolist_to_binary(TapName) || {_, #{tap_name := TapName}} <- Domains]), % TODO: persist tap_name as binary - io:format("Taps Target: ~p~n", [sets:to_list(TapsTarget)]), - io:format("Taps Actual: ~p~n", [sets:to_list(TapsActual)]), - TapsMap = maps:from_list([{iolist_to_binary(Tap), {to_vtap_mac(MacAddr), network_cidrs_to_bride_cidrs(Cidrs)}} || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), - io:format("TapsMap: ~p~n", [TapsMap]), + % io:format("Taps Target: ~p~n", [sets:to_list(TapsTarget)]), + % io:format("Taps Actual: ~p~n", [sets:to_list(TapsActual)]), + TapsMap = maps:from_list([{iolist_to_binary(Tap), {to_vtap_mac(MacAddr), network_cidrs_to_bride_cidrs(Cidrs)}} + || {_, #{network_addrs := Cidrs, tap_name := Tap, mac_addr := MacAddr}} <- Domains]), + % io:format("TapsMap: ~p~n", [TapsMap]), TapsToDelete = sets:subtract(TapsActual, TapsTarget), lists:foreach(fun (E) -> @@ -296,7 +361,8 @@ add_taps(M) when is_map(M) -> add_taps(maps:to_list(M)); add_taps([]) -> ok; add_taps([{Tap, {Mac, Bridge}}|T]) -> MacAddrString = virtuerl_util:mac_to_str(Mac), - Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s address ~s master ~s~nip link set ~s up~n", [Tap, Tap, MacAddrString, Bridge, Tap]), + Cmd = io_lib:format("ip tuntap add dev ~s mode tap~nip link set dev ~s address ~s master ~s~nip link set ~s up~n", + [Tap, Tap, MacAddrString, Bridge, Tap]), io:format(Cmd), os:cmd(Cmd), add_taps(T). diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index b6ebc47..650ddb6 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -39,29 +39,68 @@ callback_mode() -> init([ID]) -> {ok, Table} = dets:open_file(domains, [{file, filename:join(virtuerl_mgt:home_path(), "domains.dets")}]), [{DomainId, #{mac_addr:=MacAddr, tap_name := TapName} = DomainRaw}] = dets:lookup(Table, ID), - Domain = maps:merge(#{user_data => "", vcpu => 1, memory => 512}, DomainRaw), + Domain = maps:merge(#{user_data => "", vcpu => 2, memory => 4096}, DomainRaw), + State = #{table => Table, id => ID, domain => Domain, qemu_pid => undefined, qmp_pid => undefined}, + {ok, State, {continue, setup_swtpm}}. + +handle_continue(setup_swtpm, #{id := DomainId, domain := Domain} = State) -> DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId]), ok = filelib:ensure_path(DomainHomePath), + + process_flag(trap_exit, true), + file:delete(filename:join(DomainHomePath, "qmp.sock")), + file:delete(filename:join(DomainHomePath, "serial.sock")), + file:delete(filename:join(DomainHomePath, "vnc.sock")), + file:delete(filename:join(DomainHomePath, "swtpm.sock")), + + {ok, _Pid, _OsPid} = exec:run_link("swtpm socket --tpmstate dir=./ --ctrl type=unixio,path=swtpm.sock --tpm2", [{cd, DomainHomePath}]), + case wait_for_socket(filename:join(DomainHomePath, "swtpm.sock")) of + ok -> + {noreply, State, {continue, setup_base}}; + timeout -> + {stop, failure, State} + end; +handle_continue(setup_base, #{id := DomainId, domain := Domain} = State) -> + DomainHomePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainId]), + + OvmfVarsPath = filename:join(DomainHomePath, "OVMF_VARS_4M.ms.fd"), + case filelib:is_regular(OvmfVarsPath) of + false -> + file:copy("/usr/share/OVMF/OVMF_VARS_4M.ms.fd", OvmfVarsPath); + _ -> ok + end, + RootVolumePath = filename:join(DomainHomePath, "root.qcow2"), case filelib:is_regular(RootVolumePath) of false -> - BaseImagePath = filename:join([virtuerl_mgt:home_path(), "debian-12-genericcloud-amd64-20230910-1499.qcow2"]), -%% BaseImagePath = filename:join([virtuerl_mgt:home_path(), "openSUSE-Leap-15.5.x86_64-NoCloud.qcow2"]), - exec:run(lists:flatten(io_lib:format("qemu-img create -f qcow2 -b ~s -F qcow2 ~s 20G", [filename:absname(BaseImagePath), RootVolumePath])), [sync]); + BaseImageOpts = case Domain of + #{base_image := BaseImage} -> + {ok, BaseImagePath} = virtuerl_img:ensure_image(BaseImage), + ["-b ", filename:absname(BaseImagePath), " -F qcow2 "]; + _ -> [] + end, + {ok, _} = exec:run(iolist_to_binary(["qemu-img create -f qcow2 ", BaseImageOpts, RootVolumePath, " 70G"]), [sync, stderr, stdout]); _ -> noop end, - process_flag(trap_exit, true), ensure_cloud_config(Domain), - file:delete(filename:join(DomainHomePath, "qmp.sock")), - file:delete(filename:join(DomainHomePath, "serial.sock")), - file:delete(filename:join(DomainHomePath, "vnc.sock")), - #{vcpu := Vcpu, memory := Memory} = Domain, - Cmd = iolist_to_binary(["kvm -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc unix:vnc.sock -display none -serial none -smp ",integer_to_binary(Vcpu)," -m ",integer_to_binary(Memory)," -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off"]), % -serial unix:serial.sock,server=on,wait=off + #{mac_addr:=MacAddr, tap_name := TapName, vcpu := Vcpu, memory := Memory} = Domain, + CdromOpts = case Domain of + #{setup_iso := SetupIso} -> + ensure_autounattend(Domain), + [" -drive file=", filename:join("/tmp/virtuerl/cache", SetupIso), ",if=ide,index=0,media=cdrom ", + " -drive file=/tmp/virtuerl/cache/virtio-win-0.1.248.iso,if=ide,index=1,media=cdrom ", + " -drive file=autounattend.iso,if=ide,index=2,media=cdrom " + ]; + _ -> [] + end, + Cmd = iolist_to_binary(["kvm -machine type=q35 -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc unix:vnc.sock -display none -smp ",integer_to_binary(Vcpu)," -m ",integer_to_binary(Memory), + " -chardev socket,id=chrtpm,path=swtpm.sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0", + " -drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_CODE_4M.ms.fd,readonly=on", + " -drive if=pflash,format=raw,file=OVMF_VARS_4M.ms.fd", + " -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off -serial unix:serial.sock,server=on,wait=off", CdromOpts]), % -serial unix:serial.sock,server=on,wait=off io:format("QEMU cmdline: ~s~n", [Cmd]), {ok, Pid, OsPid} = exec:run_link(Cmd, [{cd, DomainHomePath}]), - State = #{table => Table, id => ID, domain => Domain, qemu_pid => {Pid, OsPid}, qmp_pid => undefined}, - {ok, State, {continue, setup_qmp}}. - + {noreply, State#{qemu_pid => {Pid, OsPid}}, {continue, setup_qmp}}; handle_continue(setup_qmp, #{id := ID} = State) -> QmpSocketPath = filename:join([virtuerl_mgt:home_path(), "domains", ID, "qmp.sock"]), io:format("waiting for qmp.sock ~p~n", [erlang:timestamp()]), @@ -101,6 +140,11 @@ handle_info({qmp, Event}, #{table := Table, id := ID, domain := Domain} = State) end; handle_info({tcp, SerialSocket, Data}, #{table := Table, id := ID, domain := Domain, serial_socket := SerialSocket} = State) -> virtuerl_pubsub:send({domain_out, ID, Data}), + {noreply, State}; + +handle_info({'EXIT', Port, normal}, State) when is_port(Port) -> + % We need this so we don't crash when open_port(...) finishes + % TODO: replace the above virtuerl_util:cmd with erlexec {noreply, State}. shutdown_events() -> @@ -136,7 +180,7 @@ terminate(_Reason, #{table := Table, id := ID, domain := Domain, qemu_pid := {Pi ok = exec:stop(Pid), receive {'EXIT', Pid, _} -> - io:format("QEMU OS process stopped!~n"), + io:format("QEMU OS process stopped! (~p)~n", [Pid]), ok; {'EXIT', OsPid, _} -> io:format("QEMU OS process stopped (OsPid)!~n"), @@ -192,7 +236,7 @@ create_cloud_config(#{id := DomainID, name := DomainName, mac_addr := MacAddr, c " dhcp4: false\n", " dhcp6: false\n", " nameservers:\n", - " addresses: [8.8.8.8, 8.8.4.4]\n", + " addresses: [8.8.8.8, 8.8.4.4, 2001:4860:4860::8888, 2001:4860:4860::8844]\n", " addresses:\n", [[ " - ", virtuerl_net:format_ip(IpAddr), "/", integer_to_binary(Prefixlen), "\n"] || {IpAddr, Prefixlen} <- Cidrs], " routes:\n", [[ @@ -218,6 +262,458 @@ create_cloud_config(#{id := DomainID, name := DomainName, mac_addr := MacAddr, c ok = file:del_dir_r(IsoBasePath), ok. +ensure_autounattend(#{id := DomainID} = Domain) -> + case filelib:is_regular(filename:join([virtuerl_mgt:home_path(), "domains", DomainID, "autounattend.iso"])) of + true -> ok; + false -> create_unattend(Domain) + end. + +create_unattend(#{id:=DomainID} = Domain) -> + DomainBasePath = filename:join([virtuerl_mgt:home_path(), "domains", DomainID]), + AutounattendPath = filename:join(DomainBasePath, "Autounattend.xml"), + UnattendPath = filename:join(DomainBasePath, "Unattend.xml"), + ok = write_unattend(Domain, AutounattendPath), + ok = write_unattend(Domain, UnattendPath), + IsoCmd = ["genisoimage -R -iso-level 4 -o ", filename:join(DomainBasePath, "autounattend.iso"), " ", AutounattendPath, " ", UnattendPath], + ok = virtuerl_util:cmd(binary_to_list(iolist_to_binary(IsoCmd))), + ok. + +write_unattend(Domain, Filename) -> + Xml = gen_unattend(Domain), + Export = xmerl:export_simple([Xml], xmerl_xml, [{prolog, ""}]), + file:write_file(Filename, iolist_to_binary(Export)). + +gen_unattend(#{id := DomainID, name := DomainName, mac_addr := MacAddr, cidrs := Cidrs}) -> + MacIdentifier = string:uppercase(string:replace(virtuerl_util:mac_to_str(MacAddr), ":", "-", all)), + GatewaysXml = [ + {'Route', [{'wcm:action', "add"}], [ + {'Identifier', [integer_to_list(Idx)]}, + {'NextHopAddress', [virtuerl_net:format_ip(virtuerl_net:bridge_addr(IpAddr, Prefixlen))]}, + {'Prefix', [virtuerl_net:format_cidr(virtuerl_net:normalize_net({IpAddr, 0}))]} + ]} + || {Idx, {IpAddr, Prefixlen}} <- lists:enumerate(Cidrs) + ], + AddressesXml = [ + {'IpAddress', [{'wcm:action', "add"}, {'wcm:keyValue', integer_to_list(Idx)}], [io_lib:format("~s/~B", [virtuerl_net:format_ip(IpAddr), Prefixlen])]} + || {Idx, {IpAddr, Prefixlen}} <- lists:enumerate(Cidrs) + ], + + DriverPaths = [ + "E:\\amd64\\w11", + "E:\\viostor\\w11\\amd64", + "E:\\NetKVM\\w11\\amd64", + "E:\\Balloon\\w11\\amd64", + "E:\\pvpanic\\w11\\amd64", + "E:\\qemupciserial\\w11\\amd64", + "E:\\qxldod\\w10\\amd64", + "E:\\vioinput\\w11\\amd64", + "E:\\viorng\\w11\\amd64", + "E:\\vioscsi\\w11\\amd64", + "E:\\vioserial\\w11\\amd64", + "E:\\vioserial\\w11\\amd64" + ], + DriverPathsXml = [ + {'PathAndCredentials', [{'wcm:action',"add"},{'wcm:keyValue',integer_to_list(Index)}], + [{'Path',[Path]}]} + || {Index, Path} <- lists:enumerate(DriverPaths)], + + Commands = [ + io_lib:format("reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\Cryptography\" /v \"MachineGuid\" /t REG_SZ /d \"~s\" /f", [DomainID]), + + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OOBE\" /v BypassNRO /t REG_DWORD /d 1 /f", + + "reg.exe load \"HKU\\mount\" \"C:\\Users\\Default\\NTUSER.DAT\"", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\Runonce\" /v \"UninstallCopilot\" /t REG_SZ /d \"powershell.exe -NoProfile -Command \\\"Get-AppxPackage -Name 'Microsoft.Windows.Ai.Copilot.Provider' | Remove-AppxPackage;\\\"\" /f", + "reg.exe add \"HKU\\mount\\Software\\Policies\\Microsoft\\Windows\\WindowsCopilot\" /v TurnOffWindowsCopilot /t REG_DWORD /d 1 /f", + "reg.exe unload \"HKU\\mount\"", + + "reg.exe delete \"HKLM\\SOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\DevHomeUpdate\" /f", + "cmd.exe /c \"del \"C:\\Users\\Default\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\OneDrive.lnk\"\"", + "cmd.exe /c \"del \"C:\\Windows\\System32\\OneDriveSetup.exe\"\"", + "cmd.exe /c \"del \"C:\\Windows\\SysWOW64\\OneDriveSetup.exe\"\"", + + "reg.exe load \"HKU\\mount\" \"C:\\Users\\Default\\NTUSER.DAT\"", + "reg.exe delete \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\" /v OneDriveSetup /f", + "reg.exe unload \"HKU\\mount\"", + + "reg.exe delete \"HKLM\\SOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\OutlookUpdate\" /f", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Communications\" /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f", + "powershell.exe -NoProfile -Command \"$xml = [xml]::new(); $xml.Load('C:\\Windows\\Panther\\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;\"", + "powershell.exe -NoProfile -Command \"Get-Content -LiteralPath '%TEMP%\\remove-packages.ps1' -Raw | Invoke-Expression;\"", + "powershell.exe -NoProfile -Command \"Get-Content -LiteralPath '%TEMP%\\remove-caps.ps1' -Raw | Invoke-Expression;\"", + "powershell.exe -NoProfile -Command \"Get-Content -LiteralPath '%TEMP%\\remove-features.ps1' -Raw | Invoke-Expression;\"", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\PolicyManager\\current\\device\\Start\" /v ConfigureStartPins /t REG_SZ /d \"{ \\\"pinnedList\\\": [] }\" /f", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\PolicyManager\\current\\device\\Start\" /v ConfigureStartPins_ProviderSet /t REG_DWORD /d 1 /f", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\PolicyManager\\current\\device\\Start\" /v ConfigureStartPins_WinningProvider /t REG_SZ /d B5292708-1619-419B-9923-E5D9F3925E71 /f", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\PolicyManager\\providers\\B5292708-1619-419B-9923-E5D9F3925E71\\default\\Device\\Start\" /v ConfigureStartPins /t REG_SZ /d \"{ \\\"pinnedList\\\": [] }\" /f", + "reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\PolicyManager\\providers\\B5292708-1619-419B-9923-E5D9F3925E71\\default\\Device\\Start\" /v ConfigureStartPins_LastWrite /t REG_DWORD /d 1 /f", + + "reg.exe load \"HKU\\mount\" \"C:\\Users\\Default\\NTUSER.DAT\"", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\Runonce\" /v \"GeoLocation\" /t REG_SZ /d \"powershell.exe -NoProfile -Command \\\"Set-WinHomeLocation -GeoId 94;\\\"\" /f", + "reg.exe unload \"HKU\\mount\"", + + "net.exe accounts /maxpwage:UNLIMITED", + "regini.exe \"%TEMP%\\disable-defender.ini\"", + "netsh.exe advfirewall firewall set rule group=\"Remote Desktop\" new enable=Yes", + "reg.exe add \"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\" /v fDenyTSConnections /t REG_DWORD /d 0 /f", + "powershell.exe -NoProfile -Command \"Set-ExecutionPolicy -Scope 'LocalMachine' -ExecutionPolicy 'RemoteSigned' -Force;\"", + "reg.exe add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Dsh\" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f", + + "reg.exe load \"HKU\\mount\" \"C:\\Users\\Default\\NTUSER.DAT\"", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"ContentDeliveryAllowed\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"FeatureManagementEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"OEMPreInstalledAppsEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"PreInstalledAppsEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"PreInstalledAppsEverEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SilentInstalledAppsEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SoftLandingEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContentEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-310093Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-338387Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-338388Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-338389Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-338393Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SubscribedContent-353698Enabled\" /t REG_DWORD /d 0 /f", + "reg.exe add \"HKU\\mount\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\" /v \"SystemPaneSuggestionsEnabled\" /t REG_DWORD /d 0 /f", + "reg.exe unload \"HKU\\mount\"", + + "reg.exe add \"HKLM\\Software\\Policies\\Microsoft\\Windows\\CloudContent\" /v \"DisableWindowsConsumerFeatures\" /t REG_DWORD /d 0 /f", + "C:\\Windows\\Setup\\Scripts\\unattend-01.cmd" + ], + ToCommands = fun (Cmds) -> + [{'RunSynchronousCommand', [{'wcm:action',"add"}], + [{'Order',[integer_to_list(Idx)]}, {'Path',[Cmd]}]} + || {Idx, Cmd} <- lists:enumerate(Cmds)] + end, + + CommandsXml = ToCommands(Commands), + +% based on: https://schneegans.de/windows/unattend-generator/?LanguageMode=Unattended&UILanguage=en-GB&UserLocale=en-GB&KeyboardLayout=0409%3A00000409&GeoLocation=94&ProcessorArchitecture=amd64&BypassNetworkCheck=true&ComputerNameMode=Custom&ComputerName=XXZZCCVVasdf&TimeZoneMode=Implicit&PartitionMode=Unattended&PartitionLayout=GPT&EspSize=300&RecoveryMode=Partition&RecoverySize=1000&WindowsEditionMode=Unattended&WindowsEdition=pro_workstations_n&UserAccountMode=Unattended&AccountName0=Admin&AccountPassword0=password&AccountGroup0=Administrators&AccountName1=User&AccountPassword1=password&AccountGroup1=Users&AccountName2=&AccountName3=&AccountName4=&AutoLogonMode=Own&PasswordExpirationMode=Unlimited&LockoutMode=Default&DisableDefender=true&DisableSystemRestore=true&EnableRemoteDesktop=true&AllowPowerShellScripts=true&DisableAppSuggestions=true&DisableWidgets=true&WifiMode=Skip&ExpressSettings=DisableAll&Remove3DViewer=true&RemoveCamera=true&RemoveClipchamp=true&RemoveClock=true&RemoveCopilot=true&RemoveCortana=true&RemoveDevHome=true&RemoveFamily=true&RemoveFeedbackHub=true&RemoveGetHelp=true&RemoveInternetExplorer=true&RemoveMailCalendar=true&RemoveMaps=true&RemoveMathInputPanel=true&RemoveZuneVideo=true&RemoveNews=true&RemoveNotepadClassic=true&RemoveOffice365=true&RemoveOneDrive=true&RemoveOneNote=true&RemoveOutlook=true&RemovePaint=true&RemovePaint3D=true&RemovePeople=true&RemovePhotos=true&RemovePowerAutomate=true&RemoveQuickAssist=true&RemoveSkype=true&RemoveSnippingTool=true&RemoveSolitaire=true&RemoveStepsRecorder=true&RemoveStickyNotes=true&RemoveTeams=true&RemoveGetStarted=true&RemoveToDo=true&RemoveVoiceRecorder=true&RemoveWeather=true&RemoveWindowsMediaPlayer=true&RemoveZuneMusic=true&RemoveWordPad=true&RemoveXboxApps=true&RemoveYourPhone=true&SystemScript0=powercfg.exe+%2FHIBERNATE+OFF&SystemScriptType0=Cmd&SystemScript1=&SystemScriptType1=Ps1&SystemScript2=&SystemScriptType2=Reg&SystemScript3=&SystemScriptType3=Vbs&DefaultUserScript0=&DefaultUserScriptType0=Reg&FirstLogonScript0=&FirstLogonScriptType0=Cmd&FirstLogonScript1=&FirstLogonScriptType1=Ps1&FirstLogonScript2=&FirstLogonScriptType2=Reg&FirstLogonScript3=&FirstLogonScriptType3=Vbs&UserOnceScript0=&UserOnceScriptType0=Cmd&UserOnceScript1=&UserOnceScriptType1=Ps1&UserOnceScript2=&UserOnceScriptType2=Reg&UserOnceScript3=&UserOnceScriptType3=Vbs&WdacMode=Skip&Microsoft-Windows-PnpCustomizationsWinPE=windowsPE&Microsoft-Windows-TCPIP=windowsPE&Microsoft-Windows-TCPIP=specialize +{unattend, + [{xmlns,"urn:schemas-microsoft-com:unattend"}, + {'xmlns:wcm',"http://schemas.microsoft.com/WMIConfig/2002/State"}], + [{settings,[{pass,"offlineServicing"}],[]}, + {settings,[{pass,"windowsPE"}], + [{component, + [{name,"Microsoft-Windows-International-Core-WinPE"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'SetupUILanguage',[{'UILanguage',["en-GB"]}]}, + {'InputLocale',["0409:00000409"]}, + {'SystemLocale',["en-GB"]}, + {'UILanguage',["en-GB"]}, + {'UserLocale',["en-GB"]}]}, + {component, + [{name,"Microsoft-Windows-Setup"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'ImageInstall', + [{'OSImage', + [{'InstallTo', + [{'DiskID',["0"]}, + {'PartitionID',["3"]}]}]}]}, + {'UserData', + [{'ProductKey', + [{'Key',["WYPNQ-8C467-V2W6J-TX4WX-WT2RQ"]}]}, + {'AcceptEula',["true"]}]}, + {'DiskConfiguration', + [{'DisableEncryptedDiskProvisioning',["true"]}, + {'Disk',[{'wcm:action',"add"}], + [{'CreatePartitions', + [{'CreatePartition',[{'wcm:action',"add"}], + [{'Order',["1"]}, + {'Type',["EFI"]}, + {'Size',["400"]}]}, + {'CreatePartition',[{'wcm:action',"add"}], + [{'Order',["2"]}, + {'Type',["MSR"]}, + {'Size',["100"]}]}, + {'CreatePartition',[{'wcm:action',"add"}], + [{'Order',["3"]}, + {'Type',["Primary"]}, + {'Extend',["true"]}]}]}, + {'ModifyPartitions', + [{'ModifyPartition',[{'wcm:action',"add"}], + [{'Format',["NTFS"]}, + {'Letter',["C"]}, + {'Order',["1"]}, + {'PartitionID',["3"]}, + {'Label',["Windows 11"]}]}]}, + {'DiskID',["0"]}, + {'WillWipeDisk',["true"]}]}, + {'WillShowUI',["OnError"]}]}]}, + {component, + [{name,"Microsoft-Windows-PnpCustomizationsWinPE"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'DriverPaths', DriverPathsXml}]}]}, + {settings,[{pass,"generalize"}],[]}, + {settings,[{pass,"specialize"}], + [{component, + [{name,"Microsoft-Windows-Deployment"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'RunSynchronous', CommandsXml}]}, + {component, + [{name,"Microsoft-Windows-TCPIP"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'Interfaces',[ + {'Interface', [{'wcm:action', "add"}], [ + {'Identifier', [MacIdentifier]}, + {'Ipv4Settings', [ + {'DhcpEnabled', ["false"]} + ]}, + {'Ipv6Settings', [ + {'DhcpEnabled', ["false"]} + ]}, + {'UnicastIpAddresses', AddressesXml}, + {'Routes', GatewaysXml} + ]} + ]}]}, + {component, + [{name,"Microsoft-Windows-DNS-Client"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'Interfaces',[ + {'Interface', [{'wcm:action', "add"}], [ + {'Identifier', [MacIdentifier]}, + {'DNSServerSearchOrder', [ + {'IpAddress', [{'wcm:action', "add"}, {'wcm:keyValue', "1"}], ["8.8.8.8"]}, + {'IpAddress', [{'wcm:action', "add"}, {'wcm:keyValue', "2"}], ["8.8.4.4"]}, + {'IpAddress', [{'wcm:action', "add"}, {'wcm:keyValue', "3"}], ["2001:4860:4860::8888"]}, + {'IpAddress', [{'wcm:action', "add"}, {'wcm:keyValue', "4"}], ["2001:4860:4860::8844"]} + ]} + ]} + ]}]}, + {component, + [{name,"Microsoft-Windows-Shell-Setup"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'ComputerName',[DomainName]}]}]}, + {settings,[{pass,"auditSystem"}],[]}, + {settings,[{pass,"auditUser"}],[ + % {component, + % [{name,"Microsoft-Windows-Deployment"}, + % {processorArchitecture,"amd64"}, + % {publicKeyToken,"31bf3856ad364e35"}, + % {language,"neutral"}, + % {versionScope,"nonSxS"}], + % [{'Generalize',[ + % {'Mode', ["OOBE"]}, + % {'ForceShutdownNow', ["true"]} + % ]}]} + ]}, + {settings,[{pass,"oobeSystem"}], + [{component, + [{name,"Microsoft-Windows-International-Core"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'InputLocale',["0409:00000409"]}, + {'SystemLocale',["en-GB"]}, + {'UILanguage',["en-GB"]}, + {'UserLocale',["en-GB"]}]}, + % {component, + % [{name,"Microsoft-Windows-Deployment"}, + % {processorArchitecture,"amd64"}, + % {publicKeyToken,"31bf3856ad364e35"}, + % {language,"neutral"}, + % {versionScope,"nonSxS"}], + % [{'ExtendOSPartition',[{'Extend', ["true"]}]}, + % {'Reseal',[ + % {'Mode', ["Audit"]}, + % {'ForceShutdownNow', ["false"]} + % ]}]}, + {component, + [{name,"Microsoft-Windows-Shell-Setup"}, + {processorArchitecture,"amd64"}, + {publicKeyToken,"31bf3856ad364e35"}, + {language,"neutral"}, + {versionScope,"nonSxS"}], + [{'UserAccounts', + [{'LocalAccounts', + [{'LocalAccount', + [{'wcm:action',"add"}], + [{'Name',["Admin"]}, + {'Group',["Administrators"]}, + {'Password', + [{'Value',["SoftwarePatchenIstFamos"]}, + {'PlainText',["true"]}]}]}, + {'LocalAccount', + [{'wcm:action',"add"}], + [{'Name',["User"]}, + {'Group',["Users"]}, + {'Password', + [{'Value',["SoftwarePatchenIstFamos"]}, + {'PlainText',["true"]}]}]}]}]}, + {'AutoLogon', + [{'Username',["Admin"]}, + {'Enabled',["true"]}, + {'LogonCount',["1"]}, + {'Password', + [{'Value',["SoftwarePatchenIstFamos"]}, + {'PlainText',["true"]}]}]}, + {'OOBE', + [{'ProtectYourPC',["3"]}, + {'HideEULAPage',["true"]}, + {'HideWirelessSetupInOOBE',["true"]}]}, + {'FirstLogonCommands', + [ + % {'SynchronousCommand', + % [{'wcm:action',"add"}], + % [{'Order',["1"]}, + % {'CommandLine', + % ["del C:\\Windows\\Panther\\unattend.xml"]}]}, + % {'SynchronousCommand', + % [{'wcm:action',"add"}], + % [{'Order',["2"]}, + % {'CommandLine', + % ["C:\\Windows\\System32\\Sysprep\\Sysprep.exe /generalize /oobe /shutdown"]}]}, + {'SynchronousCommand', + [{'wcm:action',"add"}], + [{'Order',["1"]}, + {'CommandLine', + ["reg.exe add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\" /v AutoLogonCount /t REG_DWORD /d 0 /f"]}]}, + {'SynchronousCommand', + [{'wcm:action',"add"}], + [{'Order',["2"]}, + {'CommandLine', + ["powershell.exe -NoProfile -Command \"Disable-ComputerRestore -Drive 'C:\\';\""]}]}]}]}]}, + {'Extensions', + [{xmlns,"https://schneegans.de/windows/unattend-generator/"}], + [{'ExtractScript', + ["param( + [xml] $Document +); + +$scriptsDir = 'C:\\Windows\\Setup\\Scripts\\'; +foreach( $file in $Document.unattend.Extensions.File ) { + $path = [System.Environment]::ExpandEnvironmentVariables( + $file.GetAttribute( 'path' ) + ); + if( $path.StartsWith( $scriptsDir ) ) { + mkdir -Path $scriptsDir -ErrorAction 'SilentlyContinue'; + } + $encoding = switch( [System.IO.Path]::GetExtension( $path ) ) { + { $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; } + { $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); } + default { [System.Text.Encoding]::Default; } + }; + [System.IO.File]::WriteAllBytes( $path, ( $encoding.GetPreamble() + $encoding.GetBytes( $file.InnerText ) ) ); +}"]}, + {'File', + [{path,"%TEMP%\\remove-packages.ps1"}], + ["Get-AppxProvisionedPackage -Online | +Where-Object -Property 'DisplayName' -In -Value @( + 'Microsoft.Microsoft3DViewer'; + 'Microsoft.WindowsCamera'; + 'Clipchamp.Clipchamp'; + 'Microsoft.WindowsAlarms'; + 'Microsoft.549981C3F5F10'; + 'MicrosoftCorporationII.MicrosoftFamily'; + 'Microsoft.WindowsFeedbackHub'; + 'Microsoft.GetHelp'; + 'microsoft.windowscommunicationsapps'; + 'Microsoft.WindowsMaps'; + 'Microsoft.ZuneVideo'; + 'Microsoft.BingNews'; + 'Microsoft.MicrosoftOfficeHub'; + 'Microsoft.Office.OneNote'; + 'Microsoft.Paint'; + 'Microsoft.MSPaint'; + 'Microsoft.People'; + 'Microsoft.Windows.Photos'; + 'Microsoft.PowerAutomateDesktop'; + 'MicrosoftCorporationII.QuickAssist'; + 'Microsoft.SkypeApp'; + 'Microsoft.ScreenSketch'; + 'Microsoft.MicrosoftSolitaireCollection'; + 'Microsoft.MicrosoftStickyNotes'; + 'Microsoft.Getstarted'; + 'Microsoft.Todos'; + 'Microsoft.WindowsSoundRecorder'; + 'Microsoft.BingWeather'; + 'Microsoft.ZuneMusic'; + 'Microsoft.Xbox.TCUI'; + 'Microsoft.XboxApp'; + 'Microsoft.XboxGameOverlay'; + 'Microsoft.XboxGamingOverlay'; + 'Microsoft.XboxIdentityProvider'; + 'Microsoft.XboxSpeechToTextOverlay'; + 'Microsoft.GamingApp'; + 'Microsoft.YourPhone'; +) | Remove-AppxProvisionedPackage -AllUsers -Online *>&1 >> \"$env:TEMP\\remove-packages.log\"; +"]}, + {'File', + [{path,"%TEMP%\\remove-caps.ps1"}], + ["Get-WindowsCapability -Online | +Where-Object -FilterScript { + ($_.Name -split '~')[0] -in @( + 'Browser.InternetExplorer'; + 'MathRecognizer'; + 'Microsoft.Windows.Notepad'; + 'Microsoft.Windows.MSPaint'; + 'App.Support.QuickAssist'; + 'App.StepsRecorder'; + 'Media.WindowsMediaPlayer'; + 'Microsoft.Windows.WordPad'; + ); +} | Remove-WindowsCapability -Online *>&1 >> \"$env:TEMP\\remove-caps.log\"; +"]}, + {'File', + [{path,"%TEMP%\\remove-features.ps1"}], + ["Get-WindowsOptionalFeature -Online | +Where-Object -Property 'FeatureName' -In -Value @( + 'Microsoft-SnippingTool'; +) | Disable-WindowsOptionalFeature -Online -Remove -NoRestart *>&1 >> \"$env:TEMP\\remove-features.log\"; +"]}, + {'File', + [{path,"C:\\Users\\Default\\AppData\\Local\\Microsoft\\Windows\\Shell\\LayoutModification.xml"}], + [" + + + + + + + +"]}, + {'File', + [{path,"%TEMP%\\disable-defender.ini"}], + ["HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Sense + \"Start\" = REG_DWORD 4 +HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WdBoot + \"Start\" = REG_DWORD 4 +HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WdFilter + \"Start\" = REG_DWORD 4 +HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WdNisDrv + \"Start\" = REG_DWORD 4 +HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc + \"Start\" = REG_DWORD 4 +HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WinDefend + \"Start\" = REG_DWORD 4 +"]}, + {'File', + [{path,"C:\\Windows\\Setup\\Scripts\\unattend-01.cmd"}], + ["powercfg.exe /HIBERNATE OFF"]}]}]} +. + handle_call(Request, From, State) -> erlang:error(not_implemented). diff --git a/virtuerl/src/virtuerl_stor.erl b/virtuerl/src/virtuerl_stor.erl deleted file mode 100644 index 3862075..0000000 --- a/virtuerl/src/virtuerl_stor.erl +++ /dev/null @@ -1,48 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @author ilya -%%% @copyright (C) 2023, -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(virtuerl_stor). - --behaviour(gen_server). - --export([start_link/0]). --export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, - code_change/3]). - --define(SERVER, ?MODULE). - -%%%=================================================================== -%%% Spawning and gen_server implementation -%%%=================================================================== - -start_link() -> - gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). - -init([]) -> - {ok, Table} = dets:open_file(stors, []), - {ok, {Table}}. - -handle_call({domain_delete, #{id := DomainID}}, _From, State) -> - {Table} = State, - Res = dets:delete(Table, DomainID), - dets:sync(Table), - ok = supervisor:terminate_child(virtuerl_sup, DomainID), - ok = supervisor:delete_child(virtuerl_sup, DomainID), - ok = gen_server:call(virtuerl_net, {net_update}), - {reply, Res, State}. - -handle_cast(_Request, State) -> - {noreply, State}. - -handle_info(_Info, State) -> - {noreply, State}. - -terminate(_Reason, {Table}) -> - dets:close(Table), - ok. - -code_change(_OldVsn, State, _Extra) -> - {ok, State}. diff --git a/virtuerl/src/virtuerl_sup.erl b/virtuerl/src/virtuerl_sup.erl index 72f6acb..9116f97 100644 --- a/virtuerl/src/virtuerl_sup.erl +++ b/virtuerl/src/virtuerl_sup.erl @@ -45,6 +45,13 @@ init([]) -> worker, [] }, { + virtuerl_img, + {virtuerl_img, start_link, []}, + permanent, + infinity, + worker, + [] + }, { virtuerl_mgt, {virtuerl_mgt, start_link, []}, permanent, diff --git a/virtuerl/src/virtuerl_ui.erl b/virtuerl/src/virtuerl_ui.erl index 5c92ed7..373e433 100644 --- a/virtuerl/src/virtuerl_ui.erl +++ b/virtuerl/src/virtuerl_ui.erl @@ -138,11 +138,13 @@ init([Node]) -> DomainButtonsSizer = wxBoxSizer:new(?wxHORIZONTAL), DomainDupBtn = wxButton:new(DomainInfo, 4044, [{label, "Duplicate"}]), - wxButton:connect(DomainDupBtn, command_button_clicked), DomainDelBtn = wxButton:new(DomainInfo, ?wxID_ANY, [{label, "Delete"}]), + DomainEditBtn = wxButton:new(DomainInfo, 4046, [{label, "Edit"}]), + wxButton:connect(DomainEditBtn, command_button_clicked), wxSizer:add(DomainButtonsSizer, DomainDupBtn), wxSizer:add(DomainButtonsSizer, DomainDelBtn), + wxSizer:add(DomainButtonsSizer, DomainEditBtn), wxSizer:add(DomainInfoSizer, DomainButtonsSizer, [{flag, ?wxALIGN_RIGHT}]), wxSplitterWindow:splitHorizontally(DomainSplitter, DomainListBox, DomainInfo, [{sashPosition, 25 * Mx}]), @@ -238,10 +240,18 @@ handle_event(#wx{id = 42, event = #wxCommand{type = command_listbox_selected, State = #state{info_panel = Panel, info=Info, domains = DomainIds, node = Node}) -> {ok, Nets} = erpc:call(Node, virtuerl_ipam, ipam_list_nets, []), Net = maps:get(list_to_binary(Choice), Nets), - #{cidr4 := #{address := Address, prefixlen := Prefixlen}} = Net, + Cidrs = case Net of + #{cidr4 := Cidr4, cidr6 := Cidr6} -> + [Cidr4, Cidr6]; + #{cidr4 := Cidr4} -> + [Cidr4]; + #{cidr6 := Cidr6} -> + [Cidr6] + end, + CidrsStr = [binary_to_list(iolist_to_binary([IpAddr, "/", integer_to_binary(Prefixlen)])) || #{address:=IpAddr,prefixlen:=Prefixlen} <- Cidrs], wxFlexGridSizer:clear(Info, [{delete_windows, true}]), wxSizer:add(Info, wxStaticText:new(Panel, -1, "CIDR")), - wxSizer:add(Info, wxStaticText:new(Panel, -1, iolist_to_binary([Address, "/", integer_to_binary(Prefixlen)]))), + wxSizer:add(Info, wxStaticText:new(Panel, -1, string:join(CidrsStr, ","))), io:format("dblclick ~p (~p)~n", [Choice, Net]), {noreply, State}; handle_event(#wx{event = #wxList{type = command_list_item_selected, @@ -304,6 +314,12 @@ handle_event(#wx{id = 4044, event = #wxCommand{type = command_button_clicked}}, {ok, Domain} = erpc:call(Node, virtuerl_mgt, domain_get, [#{id => DomainId}]), create_domain_dialog(Node, Domain), {noreply, State}; +handle_event(#wx{id = 4046, event = #wxCommand{type = command_button_clicked}}, #state{domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> + SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), + DomainId = lists:nth(SelectedItem + 1, DomainIds), + {ok, Domain} = erpc:call(Node, virtuerl_mgt, domain_get, [#{id => DomainId}]), + update_domain_dialog(Node, Domain), + {noreply, State}; handle_event(#wx{id = 100, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> io:format("~p~n", [Event]), SelectedItem = wxListCtrl:getNextItem(DomainListBox, -1, [{state, ?wxLIST_STATE_SELECTED}]), @@ -336,7 +352,7 @@ handle_event(#wx{id = 102, obj = Toolbar, event = #wxCommand{type = command_menu erpc:call(Node, virtuerl_mgt, domain_delete, [#{id => DomainId}]), {noreply, State}; handle_event(#wx{id = 103, obj = Toolbar, event = #wxCommand{type = command_menu_selected}} = Event, #state{page = 1, domain_list_box = DomainListBox, domains = DomainIds, node = Node} = State) -> - create_domain_dialog(Node, #{network_id => "", name=> "", user_data => "", vcpu => 2, memory => 1024}), + create_domain_dialog(Node, #{network_id => "", name=> "", user_data => "", vcpu => 2, memory => 1024, inbound_rules => [], os_type => "linux"}), {noreply, State}; %% BEGIN: Network Toolbar handle_event(#wx{id = 102, event = #wxCommand{type = command_menu_selected}}, #state{page = 0, net_list_box = ListBox, node = Node} = State) -> @@ -370,27 +386,30 @@ terminate(_Reason, _State) -> create_network_dialog(Node) -> Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Network", [{size, {1000, 500}}]), DialogSizer = wxBoxSizer:new(?wxVERTICAL), - DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), + % DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), + DialogGridSizer = wxBoxSizer:new(?wxHORIZONTAL), wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "CIDR")), - CidrCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY), + CidrCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]), wxSizer:add(DialogGridSizer, CidrCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), - wxSizer:add(DialogSizer, DialogGridSizer), + wxSizer:add(DialogSizer, DialogGridSizer, [{flag, ?wxEXPAND}, {proportion, 1}]), ButtonSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL), wxSizer:add(DialogSizer, ButtonSizer), wxPanel:setSizer(Dialog, DialogSizer), -%% wxWindow:layout(DialogSizer), case wxDialog:showModal(Dialog) of ?wxID_OK -> - NetDef = virtuerl_net:parse_cidr(wxTextCtrl:getValue(CidrCtrl)), - {ok, NetId} = erpc:call(Node, virtuerl_ipam, ipam_create_net, [[NetDef]]); + NetDef = [ + virtuerl_net:parse_cidr(string:trim(IpStr, both)) + || IpStr <- string:split(wxTextCtrl:getValue(CidrCtrl), ",", all)], + {ok, NetId} = erpc:call(Node, virtuerl_ipam, ipam_create_net, [NetDef]); _ -> ok end, wxDialog:destroy(Dialog). -create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_data := UserData, vcpu := Vcpu, memory := Memory} = Domain) -> +create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_data := UserData, vcpu := Vcpu, memory := Memory, inbound_rules := InboundRules} = Domain) -> {ok, Nets} = erpc:call(Node, virtuerl_ipam, ipam_list_nets, []), - Choices = maps:keys(Nets), + NetworkChoices = maps:keys(Nets), + ImageChoices = erpc:call(Node, virtuerl_img, list_images, []), Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Create Domain", [{size, {1000, 500}}]), DialogSizer = wxBoxSizer:new(?wxVERTICAL), DialogGridSizer = wxFlexGridSizer:new(1, 2, 0, 0), @@ -398,7 +417,7 @@ create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_da NameCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, DomainName}]), wxSizer:add(DialogGridSizer, NameCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Network")), - NetworkChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, Choices}]), + NetworkChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, NetworkChoices}]), wxChoice:setStringSelection(NetworkChoice, NetworkId), wxSizer:add(DialogGridSizer, NetworkChoice), wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "CPU")), @@ -407,7 +426,29 @@ create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_da wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Memory")), MemoryCtrl = wxSpinCtrl:new(Dialog, [{min, 128}, {max, 131072}, {initial, Memory}]), wxSizer:add(DialogGridSizer, MemoryCtrl), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "OS")), + OsChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, ["linux", "windows"]}]), + wxChoice:setStringSelection(OsChoice, "linux"), + wxSizer:add(DialogGridSizer, OsChoice), + wxSizer:add(DialogGridSizer, wxStaticText:new(Dialog, ?wxID_ANY, "Image")), + ImageChoice = wxChoice:new(Dialog, ?wxID_ANY, [{choices, ImageChoices}]), + [DefaultImage|_] = ImageChoices, + wxChoice:setStringSelection(ImageChoice, DefaultImage), + wxSizer:add(DialogGridSizer, ImageChoice), + wxSizer:add(DialogSizer, DialogGridSizer), + + % Inbound Rules + % wxBoxSizer:new(?wxHORIZONTAL), + InboundRulesInitial = string:join([ string:join([string:join(Protos, ","), string:join([case Port of + Num when is_integer(Num) -> + integer_to_list(Num); + Str when is_list(Str) orelse is_binary(Str) -> + Str + end || Port <- Ports], ","), string:join(Sources, ",")], ";") || #{protocols := Protos, target_ports := Ports, sources := Sources} <- InboundRules], "\n"), + InboundRulesCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}, {value, InboundRulesInitial}]), + wxSizer:add(DialogSizer, InboundRulesCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), + UserDataCtrl = wxStyledTextCtrl:new(Dialog), wxStyledTextCtrl:setLexer(UserDataCtrl, ?wxSTC_LEX_YAML), wxStyledTextCtrl:setText(UserDataCtrl, UserData), @@ -418,16 +459,73 @@ create_domain_dialog(Node, #{network_id := NetworkId, name:= DomainName, user_da case wxDialog:showModal(Dialog) of ?wxID_OK -> - io:format("true ~p~n", [wxChoice:getStringSelection(NetworkChoice)]), + InboundRulesVal = wxTextCtrl:getValue(InboundRulesCtrl), + Rules0 = [string:trim(Rule) || Rule <- string:split(InboundRulesVal, "\n", all)], + Rules1 = [Rule || Rule <- Rules0, not string:is_empty(Rule)], + Rules2 = [[string:trim(Elem) || Elem <- string:split(Rule, ";", all)] || Rule <- Rules1], + Rules3 = [case Rule of [Protos, Ports, Sources] -> #{ + protocols => nonempty_splitrim(Protos, ","), + target_ports => nonempty_splitrim(Ports, ","), + sources => nonempty_splitrim(Sources, ",") + } end || Rule <- Rules2], + io:format("inbound rules: ~p~n", [Rules3]), erpc:call(Node, virtuerl_mgt, domain_create, [#{ name => wxTextCtrl:getValue(NameCtrl), + os_type => wxChoice:getStringSelection(OsChoice), + base_image => wxChoice:getStringSelection(ImageChoice), network_id => list_to_binary(wxChoice:getStringSelection(NetworkChoice)), user_data => wxStyledTextCtrl:getText(UserDataCtrl), vcpu => wxSpinCtrl:getValue(VcpuCtrl), - memory => wxSpinCtrl:getValue(MemoryCtrl) + memory => wxSpinCtrl:getValue(MemoryCtrl), + inbound_rules => Rules3 }]); _ -> ok end, - wxDialog:destroy(Dialog); -create_domain_dialog(Node, Domain) -> - create_domain_dialog(Node, Domain#{user_data => ""}). + wxDialog:destroy(Dialog). + +update_domain_dialog(Node, #{id := DomainId, state := RunState, inbound_rules := InboundRules} = Domain) -> + Dialog = wxDialog:new(wx:null(), ?wxID_ANY, "Edit Domain", [{size, {1000, 500}}]), + DialogSizer = wxBoxSizer:new(?wxVERTICAL), + + % Inbound Rules + % wxBoxSizer:new(?wxHORIZONTAL), + InboundRulesInitial = string:join([ string:join([string:join(Protos, ","), string:join([case Port of + Num when is_integer(Num) -> + integer_to_list(Num); + Str when is_list(Str) orelse is_binary(Str) -> + Str + end || Port <- Ports], ","), string:join(Sources, ",")], ";") || #{protocols := Protos, target_ports := Ports, sources := Sources} <- InboundRules], "\n"), + InboundRulesCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}, {value, InboundRulesInitial}]), + wxSizer:add(DialogSizer, InboundRulesCtrl, [{flag, ?wxEXPAND}, {proportion, 1}]), + + ButtonSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxOK bor ?wxCANCEL), + wxSizer:add(DialogSizer, ButtonSizer), + wxPanel:setSizer(Dialog, DialogSizer), + + case wxDialog:showModal(Dialog) of + ?wxID_OK -> + InboundRulesVal = wxTextCtrl:getValue(InboundRulesCtrl), + Rules0 = [string:trim(Rule) || Rule <- string:split(InboundRulesVal, "\n", all)], + Rules1 = [Rule || Rule <- Rules0, not string:is_empty(Rule)], + Rules2 = [[string:trim(Elem) || Elem <- string:split(Rule, ";", all)] || Rule <- Rules1], + Rules3 = [case Rule of [Protos, Ports, Sources] -> #{ + protocols => nonempty_splitrim(Protos, ","), + target_ports => nonempty_splitrim(Ports, ","), + sources => nonempty_splitrim(Sources, ",") + } end || Rule <- Rules2], + io:format("inbound rules: ~p~n", [Rules3]), + erpc:call(Node, virtuerl_mgt, domain_update, [#{ + id => DomainId, + state => RunState, + inbound_rules => Rules3 + }]); + _ -> ok + end, + wxDialog:destroy(Dialog). + + +nonempty_splitrim(Str, Delim) -> + Res = [string:trim(Elem) || Elem <- string:split(Str, Delim, all)], + [Elem || Elem <- Res, not string:is_empty(Elem)]. + + diff --git a/virtuerl/src/virtuerl_util.erl b/virtuerl/src/virtuerl_util.erl index a253298..78717f0 100644 --- a/virtuerl/src/virtuerl_util.erl +++ b/virtuerl/src/virtuerl_util.erl @@ -1,5 +1,5 @@ %%%------------------------------------------------------------------- -%%% @author ilya-stroeer +%%% @author ilya %%% @copyright (C) 2023, %%% @doc %%% @@ -7,10 +7,10 @@ %%% Created : 02. Sep 2023 4:05 PM %%%------------------------------------------------------------------- -module(virtuerl_util). --author("ilya-stroeer"). +-author("ilya"). %% API --export([uuid4/0, mac_to_str/1, delete_file/1, cmd/1]). +-export([uuid4/0, mac_to_str/1, delete_file/1, cmd/1, ends_with/2]). uuid4() -> ID = string:lowercase(binary:encode_hex(<<(rand:uniform(16#FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)-1):128>>)), @@ -29,6 +29,10 @@ delete_file(Filename) -> Other -> Other end. +ends_with(Str, Suffix) -> + Suf = string:slice(Str, string:length(Str) - string:length(Suffix)), + string:equal(Suf, Suffix). + cmd(Cmd) -> Port = open_port({spawn, Cmd}, [exit_status]), receive diff --git a/virtuerl/src/virtuerl_vnc.erl b/virtuerl/src/virtuerl_vnc.erl index 265ed7b..c5be2a5 100644 --- a/virtuerl/src/virtuerl_vnc.erl +++ b/virtuerl/src/virtuerl_vnc.erl @@ -1,31 +1,3 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009-2021. All Rights Reserved. -%% -%% Licensed under the Apache License, Version 2.0 (the "License"); -%% you may not use this file except in compliance with the License. -%% You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, software -%% distributed under the License is distributed on an "AS IS" BASIS, -%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -%% See the License for the specific language governing permissions and -%% limitations under the License. -%% -%% %CopyrightEnd% -%% -%%%------------------------------------------------------------------- -%%% File : hello.erl -%%% Author : Matthew Harrison -%%% Description : _really_ minimal example of a wxerlang app -%%% implemented with wx_object behaviour -%%% -%%% Created : 18 Sep 2008 by Matthew Harrison -%%% Dan rewrote it to show wx_object behaviour -%%%------------------------------------------------------------------- -module(virtuerl_vnc). -include_lib("wx/include/wx.hrl"). -include_lib("wx/include/gl.hrl"). diff --git a/virtuerl/test/virtuerl_SUITE.erl b/virtuerl/test/virtuerl_SUITE.erl index 420e2c4..7ecb3aa 100644 --- a/virtuerl/test/virtuerl_SUITE.erl +++ b/virtuerl/test/virtuerl_SUITE.erl @@ -1,5 +1,5 @@ %%%------------------------------------------------------------------- -%%% @author ilya-stroeer +%%% @author ilya %%% @copyright (C) 2023, %%% @doc %%% @@ -7,20 +7,20 @@ %%% Created : 11. Sep 2023 9:48 PM %%%------------------------------------------------------------------- -module(virtuerl_SUITE). --author("ilya-stroeer"). +-author("ilya"). %% API -export([all/0, init_per_suite/1, end_per_suite/1]). --export([test_domain/1, test_network/1]). +-export([test_domain/1, test_network/1, test_create_domain/1, test_create_domain_dualstack/1]). -all() -> [test_network,test_domain]. +all() -> [test_create_domain, test_create_domain_dualstack]. init_per_suite(Config) -> {ok, _} = application:ensure_all_started(virtuerl), Config. end_per_suite(_Config) -> - ok. + application:stop(virtuerl). test_network(_Config) -> NetJson = thoas:encode(#{"network" => #{"cidr4" => "192.168.111.0/24", "cidr6" => "2001:db8::/80"}}), @@ -53,3 +53,111 @@ test_domain(_Config) -> {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {DomainUri, []}, [], []), {ok, {{_, 204, _}, _, _}} = httpc:request(delete, {NetUri, []}, [], []). + +test_create_domain(_Config) -> + {ok, NetID} = virtuerl_ipam:ipam_create_net([{<<192:8,168:8,17:8,0:8>>, 24}]), + {ok, #{id := DomId, ipv4_addr := <<"192.168.17.8">>}} = virtuerl_mgt:domain_create(#{name => "test_domain", vcpu => 1, memory => 512, network_id => NetID, + inbound_rules => [#{protocols => ["tcp"], target_ports => [80]}], + user_data => +"#cloud-config + +users: + - name: tester + passwd: $6$Cf1HnaIWk8TunKFs$40sITB7utYJbVL9kkmhVwzCW33vbq55IGSbpLp1AqOufng1qNxf8wyHj4fdp3xMAfr0yrGioiWwtRvbN58rlI. + lock_passwd: false + shell: /bin/bash + sudo: ALL=(ALL) NOPASSWD:ALL + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBDCT3LrJenezXzP9T6519IgpVCP1uv6f5iQwZ+IDdFc + +apt: + primary: + - arches: [default] + search: + - http://mirror.ipb.de/debian/ + - http://security.debian.org/debian-security + +packages: + - nginx + +runcmd: + - service nginx restart +" + }), % password: asd + {ok, {{_, 200, _}, _, _}} = wait_for_http("http://192.168.17.8/", 5*60*1000), + + % make sure address is actually released and reused + virtuerl_pubsub:subscribe(), + virtuerl_mgt:domain_delete(#{id => DomId}), + receive + {domain_deleted, DomId} ->ok + end, + {ok, #{id := Dom2Id, ipv4_addr := <<"192.168.17.8">>}} = virtuerl_mgt:domain_create(#{name => "test_domain_2", vcpu => 1, memory => 512, network_id => NetID, user_data => ""}), + virtuerl_mgt:domain_delete(#{id => Dom2Id}), + receive + {domain_deleted, Dom2Id} ->ok + end, + + virtuerl_ipam:ipam_delete_net(NetID), + + ok. + +test_create_domain_dualstack(_Config) -> + {ok, NetID} = virtuerl_ipam:ipam_create_net([{<<192:8,168:8,17:8,0:8>>, 24}, {<<16#fd58:16, 16#40cb:16, 16#bddb:16, 0:80>>, 48}]), + {ok, #{id := DomId, ipv4_addr := <<"192.168.17.8">>, ipv6_addr := <<"fd58:40cb:bddb::8">>}} = virtuerl_mgt:domain_create(#{name => "test_domain", vcpu => 1, memory => 512, network_id => NetID, + inbound_rules => [#{protocols => ["tcp"], target_ports => [80]}], + user_data => +"#cloud-config + +users: + - name: tester + passwd: $6$Cf1HnaIWk8TunKFs$40sITB7utYJbVL9kkmhVwzCW33vbq55IGSbpLp1AqOufng1qNxf8wyHj4fdp3xMAfr0yrGioiWwtRvbN58rlI. + lock_passwd: false + shell: /bin/bash + sudo: ALL=(ALL) NOPASSWD:ALL + ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBDCT3LrJenezXzP9T6519IgpVCP1uv6f5iQwZ+IDdFc + +apt: + primary: + - arches: [default] + search: + - http://mirror.ipb.de/debian/ + - http://security.debian.org/debian-security + +packages: + - nginx + +runcmd: + - service nginx restart +" + }), % password: asd + {ok, {{_, 200, _}, _, _}} = wait_for_http("http://[fd58:40cb:bddb::8]/", 5*60*1000), + {ok, {{_, 200, _}, _, _}} = wait_for_http("http://192.168.17.8/", 5*60*1000), + + virtuerl_pubsub:subscribe(), + virtuerl_mgt:domain_delete(#{id => DomId}), + receive + {domain_deleted, DomId} ->ok + end, + + virtuerl_ipam:ipam_delete_net(NetID), + + ok. + +wait_for_http(Url, Timeout) -> + Deadline = erlang:system_time(millisecond) + Timeout, + do_wait_for_http(Url, Deadline). + +do_wait_for_http(Url, Deadline) -> + case httpc:request(get, {Url, []}, [{timeout, 1000}], []) of + {error, _} -> + case erlang:system_time(millisecond) > Deadline of + true -> + {error, timeout}; + false -> + timer:sleep(2000), + do_wait_for_http(Url, Deadline) + end; + Res -> Res + end. diff --git a/virtuerl/virtuerl.iml b/virtuerl/virtuerl.iml deleted file mode 100644 index fb381e8..0000000 --- a/virtuerl/virtuerl.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 1eb63ca35de4de04d56a5d53071f10fa3db2a4a3 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 1 Jun 2024 22:00:58 +0200 Subject: [PATCH 40/51] build: drop restvirt build --- .github/workflows/build.yaml | 140 -------------------------------- .github/workflows/virtuerl.yaml | 2 +- 2 files changed, 1 insertion(+), 141 deletions(-) delete mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 992ae3e..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,140 +0,0 @@ -name: Build -on: - push: - branches-ignore: - - main -jobs: - restvirt: - name: Restvirt - runs-on: self-hosted - steps: - - name: Set up Python 3.10.6 - id: python - uses: actions/setup-python@v4 - with: - python-version: 3.10.6 - - name: Check out code - uses: actions/checkout@v3 - - name: Install dependencies - run: | - sudo apt update - sudo apt install -y libvirt-dev rebar3 - pip install -r requirements.txt -r requirements-dev.txt - - name: Lint - run: | - black --check --diff --color ./ - isort --check --diff --color ./ - - name: Unit Tests - run: | - tmp_dir=$(mktemp -d) - chmod -R 0711 "${tmp_dir}" - sudo iptables -P FORWARD ACCEPT - sudo ${{ steps.python.outputs.python-path }} -m pytest tests/unit - - name: Build Snap - run: | - sudo snap install --classic snapcraft - sudo usermod --append --groups lxd $(whoami) - sudo lxd init --auto - snapcraft --use-lxd - - name: Setup Virtuerl - working-directory: virtuerl - run: | - sudo apt install -y g++ - sudo rebar3 release - - cat << EOF | sudo tee -a /etc/systemd/system/virtuerl.service - [Unit] - Description=Virtuerl - After=network.target - - [Service] - Environment="SHELL=/bin/sh" - WorkingDirectory=${PWD}/_build/default/rel/virtuerl/ - ExecStart=${PWD}/_build/default/rel/virtuerl/bin/virtuerl foreground - Restart=always - - [Install] - WantedBy=multi-user.target - EOF - - sudo systemctl --now enable virtuerl - - name: Integration Tests - run: | - sudo snap install --dangerous minivirt*.snap - sudo snap connect minivirt:network-control - sudo snap connect minivirt:firewall-control - sudo snap connect minivirt:libvirt - cat << EOF | sudo tee -a /var/snap/minivirt/common/ca.crt - -----BEGIN CERTIFICATE----- - MIICCjCCAY+gAwIBAgIUSl7KWjtgvG9rNMz7hhYRKy5LsB8wCgYIKoZIzj0EAwIw - RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp - cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMjUyMFoXDTMzMDcwNTIz - MjUyMFowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI - bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID - YgAEI3nOFzsWO3w8qGLSjDSiX3OWCH7qBRcTjt/luPjXLqe3DVcFQPLYN31PaggR - o0jCjrKklxqtzHmmMdMRnyoRPbQOQPRa9N177a2s97M5ZJQVkeFL8WRUf7x1P0Cd - SZvco0IwQDAdBgNVHQ4EFgQUde9ormRTZys4Nt81qAPcSm1qQWMwDwYDVR0TAQH/ - BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwIDaQAwZgIxAJTpUOUz - RJwMLNUEa4qIgdamMuqyl5h6ghT9zX5BLsX3cFs+MqJ/J0HcKDJd81lVlQIxAPCG - hy/zgj6wy28S8GWe8KdbZ73BJtC5MyOu6hHD9EpZ1hT8K3q0VIwMEyUMmbv3Xw== - -----END CERTIFICATE----- - EOF - cat << EOF | sudo tee -a /var/snap/minivirt/common/server.crt - -----BEGIN CERTIFICATE----- - MIICeTCCAf+gAwIBAgIUVG1gWhFwRQ5kzxwRzF6V5h6D8ZYwCgYIKoZIzj0EAwIw - RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp - cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMzA0MloXDTI1MDcwNzIz - MzA0MlowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI - bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID - YgAEHWV9eL3/egpqcgTaMDPWga2xpfTZCc66yNxkVGPsw5BWE/EXvWtuUCjDmHWo - HOdrbt7iI9lA9VnSwlC9PeIvX4lK2dXNOpn3GJlZ8JkjpZZBg0mxaUt6vQMyGSco - cOOAo4GxMIGuMB8GA1UdIwQYMBaAFHXvaK5kU2crODbfNagD3EptakFjMAwGA1Ud - EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMB - BggrBgEFBQcDAjAsBgNVHREEJTAjgglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAA - AAAAAAAAAAEwHQYDVR0OBBYEFDtlzMapZ4eV0/m8ina1GM3biELeMAoGCCqGSM49 - BAMCA2gAMGUCMECXLmHsWMTaFRK+qWaBRZMLuhFNixMsSmmHHIqGlvIrWFa5MiN6 - RaZ7aTGa/HMKZAIxAPRJZ11Vp1BNBszSiswk32hsck4JP9h1hn00IMu33iK0+q22 - Jv73oZy3l4gQmLlCDg== - -----END CERTIFICATE----- - EOF - cat << EOF | sudo tee -a /var/snap/minivirt/common/server.key - -----BEGIN PRIVATE KEY----- - MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDCIJQuTNENeEnhjCtdV - GXoFgh69LQ+Ms5B/i0jWMSqMALL26uG6NNM4nvHgIMbChKGhZANiAAQdZX14vf96 - CmpyBNowM9aBrbGl9NkJzrrI3GRUY+zDkFYT8Re9a25QKMOYdagc52tu3uIj2UD1 - WdLCUL094i9fiUrZ1c06mfcYmVnwmSOllkGDSbFpS3q9AzIZJyhw44A= - -----END PRIVATE KEY----- - EOF - sudo snap set minivirt controller.args='--debug -b :8093 -c $SNAP_COMMON --server-cert $SNAP_COMMON/server.crt --server-key $SNAP_COMMON/server.key --client-ca-cert $SNAP_COMMON/ca.crt' - sudo snap start --enable minivirt.unbound - sudo snap start --enable minivirt.controller - - sleep 5 - - sudo minivirt.register -a 127.0.0.1:8093 --name default -b 127.0.0.1:8099 --client-cert /var/snap/minivirt/common/server.crt --client-key /var/snap/minivirt/common/server.key --server-ca-cert /var/snap/minivirt/common/ca.crt - sudo snap set minivirt daemon.args='--debug -a 127.0.0.1:8093 -b 127.0.0.1:8099 -c $SNAP_COMMON --client-cert $SNAP_COMMON/server.crt --client-key $SNAP_COMMON/server.key --server-ca-cert $SNAP_COMMON/ca.crt' - sudo snap start --enable minivirt.daemon - - sleep 10 - if ! sudo ${{ steps.python.outputs.python-path }} -m pytest tests/integration ; then - sudo journalctl - exit 1 - fi -# sleep 5 -# snap services minivirt -# sudo journalctl -e -# sudo apt install -y net-tools -# sudo netstat -tulpen -# sudo ${{ steps.python.outputs.python-path }} -m pytest tests/integration -# sudo journalctl -e -# sudo netstat -tulpen -# - name: Build -# run: | -# docker build --target test -t restvirt-tests . -# docker build -t restvirt . -# - name: Test -# run: | -# tmp_dir=$(mktemp -d) -# chmod -R 0711 "${tmp_dir}" -# iptables -P FORWARD ACCEPT -# docker run --rm --cap-add=NET_ADMIN --network host -t -v /var/run/libvirt:/var/run/libvirt -v "${tmp_dir}":/data/restvirt/images restvirt-tests --pool-dir "${tmp_dir}" diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index 3fe2ed2..ded11ec 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -6,7 +6,7 @@ on: jobs: virtuerl: name: virtuerl - runs-on: ubuntu-22.04 + runs-on: self-hosted defaults: run: working-directory: virtuerl From 633eda5fa74ff24e8ebf6fc6b0526f9be3ee31d2 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 1 Jun 2024 22:10:41 +0200 Subject: [PATCH 41/51] build: fix virtuerl build --- .github/workflows/virtuerl.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index ded11ec..50619c7 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -18,8 +18,8 @@ jobs: - name: Install prerequisites run: | sudo apt update - sudo apt install rebar3 + sudo apt install -y rebar3 g++ tree - name: Create tar run: | - rebar3 tar - find _build/ -name '*.tar.gz' -exec hack/repack {} \; + sudo rebar3 tar + sudo find _build/ -name '*.tar.gz' -exec hack/repack {} \; From 368b9bab8c3524226d5722ecf891d3df1e356a54 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 20:51:59 +0200 Subject: [PATCH 42/51] virtuerl: improve logging --- virtuerl/src/virtuerl_mgt.erl | 16 +++++++++++----- virtuerl/src/virtuerl_qemu.erl | 28 ++++++++++++++++++---------- virtuerl/src/virtuerl_qmp.erl | 5 +++-- virtuerl/src/virtuerl_ui.erl | 5 +++-- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/virtuerl/src/virtuerl_mgt.erl b/virtuerl/src/virtuerl_mgt.erl index f2b085e..db4b6b0 100644 --- a/virtuerl/src/virtuerl_mgt.erl +++ b/virtuerl/src/virtuerl_mgt.erl @@ -6,6 +6,8 @@ %%%------------------------------------------------------------------- -module(virtuerl_mgt). +-include_lib("kernel/include/logger.hrl"). + -export([image_from_domain/2]). -export([domain_update/1]). @@ -118,6 +120,7 @@ handle_call({domain_create, Conf}, _From, State) -> end, dets:insert_new(Table, {DomainID, Domain}), dets:sync(Table), + ?LOG_NOTICE(#{event => domain_requested, domain => Domain}), #{network_id := NetworkID} = Domain, {ok, #{cidrs := Cidrs}} = virtuerl_ipam:ipam_get_net(NetworkID), @@ -156,19 +159,21 @@ handle_call({domain_create, Conf}, _From, State) -> Domains = dets:match_object(Table, '_'), TapNames = sets:from_list([Tap || #{tap_name := Tap} <- Domains]), - TapName = generate_unique_tap_name(TapNames), + TapName = generate_unique_tap_name(TapNames), % TODO: TapName should be generated on a per-deployment basis <> = <<(rand:uniform(16#ffffffffffff)):48>>, MacAddr = <>, - dets:insert(Table, {DomainID, - Domain#{ + DomainWithIps = Domain#{ network_addrs => Cidrs, mac_addr=>MacAddr, ipv4_addr=>Ipv4Addr, ipv6_addr => Ipv6Addr, cidrs => IpCidrs, - tap_name => TapName}}), + tap_name => TapName}, + dets:insert(Table, {DomainID, DomainWithIps}), dets:sync(Table), + ?LOG_NOTICE(#{event => domain_ready, domain => DomainWithIps}), + virtuerl_pubsub:send({domain_created, DomainID}), ok = gen_server:call(virtuerl_net, {net_update}), @@ -190,8 +195,9 @@ handle_call({domain_update, #{id := DomainID} = DomainUpdate0}, _From, {Table} = [{_, Domain}] -> ok = dets:insert(Table, {DomainID, maps:merge(Domain, DomainUpdate)}), ok = dets:sync(Table), + virtuerl_pubsub:send({domain_updated, DomainID}), ok; - [] -> notfound + [] -> {error, notfound} end, {reply, Reply, State, {continue, sync_domains}}; handle_call(domains_list, _From, State) -> diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index 650ddb6..e9d97bb 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -6,6 +6,8 @@ %%%------------------------------------------------------------------- -module(virtuerl_qemu). +-include_lib("kernel/include/logger.hrl"). + -behaviour(gen_server). -export([start_link/1, callback_mode/0]). @@ -98,7 +100,7 @@ handle_continue(setup_base, #{id := DomainId, domain := Domain} = State) -> " -drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_CODE_4M.ms.fd,readonly=on", " -drive if=pflash,format=raw,file=OVMF_VARS_4M.ms.fd", " -drive file=root.qcow2,if=virtio -drive driver=raw,file=cloud_config.iso,if=virtio -qmp unix:qmp.sock,server=on,wait=off -serial unix:serial.sock,server=on,wait=off", CdromOpts]), % -serial unix:serial.sock,server=on,wait=off - io:format("QEMU cmdline: ~s~n", [Cmd]), + ?LOG_DEBUG(#{domain => DomainId, qemu_cmd => Cmd}), {ok, Pid, OsPid} = exec:run_link(Cmd, [{cd, DomainHomePath}]), {noreply, State#{qemu_pid => {Pid, OsPid}}, {continue, setup_qmp}}; handle_continue(setup_qmp, #{id := ID} = State) -> @@ -128,7 +130,7 @@ handle_continue(setup_serial, #{id := ID} = State) -> %% end. handle_info({qmp, Event}, #{table := Table, id := ID, domain := Domain} = State) -> - io:format("QMP: ~p~n", [Event]), + ?LOG_INFO(#{domain => ID, qmp => Event}), case Event of #{<<"event">> := <<"STOP">>} -> [{DomainId, Domain}] = dets:lookup(Table, ID), @@ -164,28 +166,34 @@ exit_events() -> end. terminate(_Reason, #{table := Table, id := ID, domain := Domain, qemu_pid := {Pid, OsPid}, qmp_pid := QmpPid}) -> - io:format("GRACEFUL SHUTDOWN: ~s (~p)~n", [ID, _Reason]), + ?LOG_DEBUG(#{domain => ID, event => graceful_shutdown, reason => _Reason}), case _Reason of normal -> ok; _ -> % supervisor sends "shutdown" virtuerl_qmp:exec(QmpPid, system_powerdown), + ?LOG_DEBUG(#{domain => ID, message => "waiting for guest to shutdown"}), %% shutdown_events(), receive {qmp, #{<<"event">> := <<"STOP">>}} -> ok - after 5000 -> timeout + after 5000 -> + ?LOG_WARNING(#{domain => ID, message => "timed-out waiting for guest to shutdown"}), + {error, timeout} end end, %% {ok, #{<<"return">> := #{}}} = thoas:decode(PowerdownRes), ok = virtuerl_qmp:stop(QmpPid), ok = exec:stop(Pid), + ?LOG_DEBUG(#{domain => ID, message => "waiting for QEMU process to stop"}), receive {'EXIT', Pid, _} -> - io:format("QEMU OS process stopped! (~p)~n", [Pid]), + ?LOG_DEBUG("QEMU OS process stopped! (~p)~n", [Pid]), ok; {'EXIT', OsPid, _} -> - io:format("QEMU OS process stopped (OsPid)!~n"), + ?LOG_DEBUG("QEMU OS process stopped (OsPid)!~n"), ok - after 5000 -> timeout + after 5000 -> + ?LOG_WARNING(#{domain => ID, message => "timed-out waiting for QEMU process to stop"}), + {error, timeout} end, %% exit_events(), dets:close(Table). @@ -201,16 +209,16 @@ wait_for_socket(SocketPath) -> end), receive {virtuerl, socket_available} -> - io:format("done waiting for ~s ~p~n", [SocketPath, erlang:timestamp()]), + ?LOG_DEBUG("done waiting for ~s ~p~n", [SocketPath, erlang:timestamp()]), ok after 2000 -> - io:format("failed waiting"), + ?LOG_DEBUG("failed waiting"), exit(WaiterPid, kill), timeout end. do_wait_for_socket(SocketPath, Requester) -> - io:format("checking...~n"), + ?LOG_DEBUG("checking...~n"), case filelib:last_modified(SocketPath) of 0 -> timer:sleep(20), diff --git a/virtuerl/src/virtuerl_qmp.erl b/virtuerl/src/virtuerl_qmp.erl index c1c736b..4edfa7d 100644 --- a/virtuerl/src/virtuerl_qmp.erl +++ b/virtuerl/src/virtuerl_qmp.erl @@ -6,6 +6,8 @@ %%%------------------------------------------------------------------- -module(virtuerl_qmp). +-include_lib("kernel/include/logger.hrl"). + -behaviour(gen_server). -export([start_link/2, handle_cast/2]). @@ -80,10 +82,9 @@ qmp_translator(QmpSocketPath, Receiver) -> qmp_loop(QmpSocket, Receiver) -> receive {tcp, _Socket, RawData} -> - io:format("qmp_loop/tcp/raw: ~p~n", [RawData]), Lines = re:split(RawData, "\r?\n", [trim]), Jsons = lists:map(fun (Line) -> {ok, Json} = thoas:decode(Line), Json end, Lines), - io:format("qmp_loop/tcp: ~p~n", [Jsons]), + ?LOG_DEBUG(#{qmp_raw => RawData, qmp_parsed => Jsons}), [Receiver ! {qmp, Json} || Json <- Jsons], qmp_loop(QmpSocket, Receiver); {qmp, Command} when is_atom(Command) -> diff --git a/virtuerl/src/virtuerl_ui.erl b/virtuerl/src/virtuerl_ui.erl index 373e433..7132c56 100644 --- a/virtuerl/src/virtuerl_ui.erl +++ b/virtuerl/src/virtuerl_ui.erl @@ -27,6 +27,7 @@ %%% Dan rewrote it to show wx_object behaviour %%%------------------------------------------------------------------- -module(virtuerl_ui). +-include_lib("kernel/include/logger.hrl"). -include_lib("wx/include/wx.hrl"). -export([start/0, start/1, @@ -223,8 +224,8 @@ handle_info({domain_out, _Id, Text}, #state{domain_panel = DomainPanel} = State) wxStyledTextCtrl:appendText(SerialOut, Text), wxStyledTextCtrl:scrollToLine(SerialOut, wxStyledTextCtrl:getLineCount(SerialOut)), {noreply,State}; -handle_info(Msg, #state{domain_panel = DomainPanel} = State) -> - io:format("Got Info ~p~n",[Msg]), +handle_info(Msg, State) -> + ?LOG_INFO(#{info => Msg}), {noreply, State}. handle_call(Msg, _From, State) -> From 64e5b152953504352c6cf53d9ade204136e140ef Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 22:13:21 +0200 Subject: [PATCH 43/51] virtuerl: run ghac if config is provided --- virtuerl/src/virtuerl_app.erl | 9 +++++++++ virtuerl/src/virtuerl_ghac.erl | 18 ++++++++++++------ virtuerl/src/virtuerl_sup.erl | 6 +++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/virtuerl/src/virtuerl_app.erl b/virtuerl/src/virtuerl_app.erl index 361e003..507cc22 100644 --- a/virtuerl/src/virtuerl_app.erl +++ b/virtuerl/src/virtuerl_app.erl @@ -21,6 +21,15 @@ start(_StartType, _StartArgs) -> %% {ok, _} = Res, %% exec:debug(4), httpc:set_options([{ipfamily, inet6fb4}]), + + case filelib:is_file("virtuerl.config") of + true -> + {ok, [Conf]} = file:consult("virtuerl.config"), + application:set_env(Conf); + false -> + ok + end, + virtuerl_sup:start_link(). start() -> diff --git a/virtuerl/src/virtuerl_ghac.erl b/virtuerl/src/virtuerl_ghac.erl index d1b00bd..36d9901 100644 --- a/virtuerl/src/virtuerl_ghac.erl +++ b/virtuerl/src/virtuerl_ghac.erl @@ -19,11 +19,17 @@ % repo="restvirt", % token="230b9671f90e4ff0f1f722776a6ef7e4620d97d0", --define(HEADERS, [{"User-Agent", "terstegen"}, {"Authorization", "Bearer 230b9671f90e4ff0f1f722776a6ef7e4620d97d0"}]). --define(BASE_URL, "https://api.github.com/repos/verbit/restvirt"). +base_url() -> + {ok, Org} = application:get_key(gh_org), + {ok, Repo} = application:get_key(gh_repo), + ["https://api.github.com/repos/", Org, "/", Repo]. + +headers() -> + {ok, Token} = application:get_key(gh_pat), + [{"User-Agent", "terstegen"}, {"Authorization", ["Bearer ", Token]}]. pending_jobs() -> - {ok, {{_, 200, _}, _Headers, RunsRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runs?status=queued"], ?HEADERS}, [], []), + {ok, {{_, 200, _}, _Headers, RunsRaw}} = httpc:request(get, {[base_url(), "/actions/runs?status=queued"], headers()}, [], []), {ok, RunsJson} = thoas:decode(RunsRaw), #{<<"workflow_runs">> := WorkflowRuns} = RunsJson, RunIds = [RunId || #{<<"id">> := RunId} = Run <- WorkflowRuns], @@ -32,12 +38,12 @@ pending_jobs() -> NumJobs. list_jobs(RunId) -> - {ok, {{_, 200, _}, _Headers, JobsRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runs/", RunId, "/jobs"], ?HEADERS}, [], []), + {ok, {{_, 200, _}, _Headers, JobsRaw}} = httpc:request(get, {[base_url(), "/actions/runs/", RunId, "/jobs"], headers()}, [], []), {ok, JobsJson} = thoas:decode(JobsRaw), JobsJson. list_runners() -> - {ok, {{_, 200, _}, _Headers, RunnersRaw}} = httpc:request(get, {[?BASE_URL, "/actions/runners"], ?HEADERS}, [], []), + {ok, {{_, 200, _}, _Headers, RunnersRaw}} = httpc:request(get, {[base_url(), "/actions/runners"], headers()}, [], []), {ok, RunnersJson} = thoas:decode(RunnersRaw), #{<<"runners">> := Runners} = RunnersJson, [Runner || #{<<"status">> := Status} = Runner <- Runners, Status == <<"online">>]. @@ -49,7 +55,7 @@ list_domains() -> string:prefix(Name, "actions-base") == nomatch]. create_runner(NetId) -> - {ok, {{_, 201, _}, _Headers, TokenRaw}} = httpc:request(post, {[?BASE_URL, "/actions/runners/registration-token"], ?HEADERS, "application/json", ""}, [], []), + {ok, {{_, 201, _}, _Headers, TokenRaw}} = httpc:request(post, {[base_url(), "/actions/runners/registration-token"], headers(), "application/json", ""}, [], []), {ok, #{<<"token">> := Token}} = thoas:decode(TokenRaw), {ok, _} = virtuerl_mgt:domain_create(#{ diff --git a/virtuerl/src/virtuerl_sup.erl b/virtuerl/src/virtuerl_sup.erl index 9116f97..ebbb9db 100644 --- a/virtuerl/src/virtuerl_sup.erl +++ b/virtuerl/src/virtuerl_sup.erl @@ -75,6 +75,10 @@ init([]) -> [] } ], - {ok, {SupFlags, ChildSpecs}}. + OptionalChildSpecs = case application:get_env(gh_pat) of + undefined -> []; + _ -> [{virtuerl_ghac, {virtuerl_ghac, start_link, []}, permanent, infinity, worker}] + end, + {ok, {SupFlags, ChildSpecs ++ OptionalChildSpecs}}. %% internal functions From 5250a2c3b09ee7f0e50b14b9746915fc3e65000b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 22:15:24 +0200 Subject: [PATCH 44/51] virtuerl: switch CPU model to host passthrough --- virtuerl/src/virtuerl_qemu.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtuerl/src/virtuerl_qemu.erl b/virtuerl/src/virtuerl_qemu.erl index e9d97bb..865e5c0 100644 --- a/virtuerl/src/virtuerl_qemu.erl +++ b/virtuerl/src/virtuerl_qemu.erl @@ -95,7 +95,7 @@ handle_continue(setup_base, #{id := DomainId, domain := Domain} = State) -> ]; _ -> [] end, - Cmd = iolist_to_binary(["kvm -machine type=q35 -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc unix:vnc.sock -display none -smp ",integer_to_binary(Vcpu)," -m ",integer_to_binary(Memory), + Cmd = iolist_to_binary(["kvm -machine type=q35 -no-shutdown -S -nic tap,ifname=",TapName,",script=no,downscript=no,model=virtio-net-pci,mac=",virtuerl_util:mac_to_str(MacAddr), " -vnc unix:vnc.sock -display none -cpu host -smp ",integer_to_binary(Vcpu)," -m ",integer_to_binary(Memory), " -chardev socket,id=chrtpm,path=swtpm.sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0", " -drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_CODE_4M.ms.fd,readonly=on", " -drive if=pflash,format=raw,file=OVMF_VARS_4M.ms.fd", From eb540e46d8190d97a426032b2ea1a588d1d9b19a Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 22:52:01 +0200 Subject: [PATCH 45/51] make virtuerl top-level project --- .dockerignore | 4 - .flake8 | 3 - .gitignore | 32 +- Dockerfile | 42 - README.md | 78 +- {virtuerl/config => config}/sys.config | 0 examples/docker-compose.yml | 21 - {virtuerl/hack => hack}/repack | 0 minivirt/__init__.py | 0 minivirt/controller.py | 193 --- minivirt/controller_pb2.py | 33 - minivirt/controller_pb2_grpc.py | 1260 ----------------- minivirt/daemon.py | 894 ------------ minivirt/daemon_pb2.py | 32 - minivirt/daemon_pb2_grpc.py | 862 ----------- minivirt/dns_controller.py | 104 -- minivirt/dns_pb2.py | 37 - minivirt/dns_pb2_grpc.py | 166 --- minivirt/domain_pb2.py | 60 - minivirt/domain_pb2_grpc.py | 331 ----- minivirt/host.py | 126 -- minivirt/host_pb2.py | 43 - minivirt/host_pb2_grpc.py | 232 --- minivirt/image.py | 91 -- minivirt/main.py | 297 ---- minivirt/migrations.py | 116 -- minivirt/models.py | 132 -- minivirt/port_forwarding.py | 301 ---- minivirt/port_forwarding_pb2.py | 37 - minivirt/port_forwarding_pb2_grpc.py | 166 --- minivirt/route.py | 133 -- minivirt/route_pb2.py | 49 - minivirt/route_pb2_grpc.py | 331 ----- minivirt/utils.py | 39 - minivirt/version.py | 1 - minivirt/volume_pb2.py | 49 - minivirt/volume_pb2_grpc.py | 331 ----- protos/minivirt/controller.proto | 60 - protos/minivirt/daemon.proto | 44 - protos/minivirt/dns.proto | 34 - protos/minivirt/domain.proto | 113 -- protos/minivirt/host.proto | 46 - protos/minivirt/port_forwarding.proto | 38 - protos/minivirt/route.proto | 67 - protos/minivirt/volume.proto | 73 - pyproject.toml | 18 - virtuerl/rebar.config => rebar.config | 0 virtuerl/rebar.lock => rebar.lock | 0 requirements-dev.txt | 5 - requirements.txt | 14 - setup.py | 31 - snap/hooks/configure | 19 - snap/hooks/install | 3 - snap/local/bin/bird-wrapper | 3 - snap/local/bin/birdc-wrapper | 3 - snap/local/bin/restvirt-controller | 3 - snap/local/bin/restvirt-daemon | 3 - snap/local/bin/restvirt-deregister | 3 - snap/local/bin/restvirt-register | 3 - snap/local/bin/unbound-wrapper | 3 - snap/local/etc/bird/minivirt.conf | 229 --- snap/local/etc/unbound/minivirt.conf | 20 - snap/snapcraft.yaml | 83 -- {virtuerl/src => src}/virtuerl.app.src | 0 {virtuerl/src => src}/virtuerl_api.erl | 0 {virtuerl/src => src}/virtuerl_app.erl | 0 {virtuerl/src => src}/virtuerl_ghac.erl | 0 {virtuerl/src => src}/virtuerl_img.erl | 0 {virtuerl/src => src}/virtuerl_ipam.erl | 0 {virtuerl/src => src}/virtuerl_mgt.erl | 0 {virtuerl/src => src}/virtuerl_net.erl | 0 {virtuerl/src => src}/virtuerl_pubsub.erl | 0 {virtuerl/src => src}/virtuerl_qemu.erl | 0 {virtuerl/src => src}/virtuerl_qmp.erl | 0 {virtuerl/src => src}/virtuerl_sup.erl | 0 {virtuerl/src => src}/virtuerl_ui.erl | 0 {virtuerl/src => src}/virtuerl_util.erl | 0 {virtuerl/src => src}/virtuerl_vnc.erl | 0 {virtuerl/src => src}/virtuerl_vnc_proxy.erl | 0 {virtuerl/test => test}/ipam.erl | 0 {virtuerl/test => test}/scheduler.erl | 0 {virtuerl/test => test}/virtuerl_SUITE.erl | 0 tests/integration/test_integration.py | 211 --- tests/unit/__init__.py | 0 tests/unit/conftest.py | 231 --- tests/unit/test_dns.py | 151 -- tests/unit/test_domain.py | 110 -- tests/unit/test_host.py | 52 - tests/unit/test_image.py | 35 - tests/unit/test_port_forwarding.py | 141 -- tests/unit/test_route.py | 153 -- virtuerl/.gitignore | 25 - virtuerl/.idea/.gitignore | 5 - virtuerl/.idea/codeStyles/Project.xml | 7 - virtuerl/.idea/codeStyles/codeStyleConfig.xml | 5 - virtuerl/.idea/modules.xml | 21 - virtuerl/.idea/vcs.xml | 6 - virtuerl/LICENSE.md | 186 --- virtuerl/README.md | 57 - virtuerl/Vagrantfile | 77 - virtuerl/bird.conf | 171 --- virtuerl/erlang_ls.config | 9 - 102 files changed, 71 insertions(+), 9126 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .flake8 delete mode 100644 Dockerfile rename {virtuerl/config => config}/sys.config (100%) delete mode 100644 examples/docker-compose.yml rename {virtuerl/hack => hack}/repack (100%) delete mode 100644 minivirt/__init__.py delete mode 100644 minivirt/controller.py delete mode 100644 minivirt/controller_pb2.py delete mode 100644 minivirt/controller_pb2_grpc.py delete mode 100644 minivirt/daemon.py delete mode 100644 minivirt/daemon_pb2.py delete mode 100644 minivirt/daemon_pb2_grpc.py delete mode 100644 minivirt/dns_controller.py delete mode 100644 minivirt/dns_pb2.py delete mode 100644 minivirt/dns_pb2_grpc.py delete mode 100644 minivirt/domain_pb2.py delete mode 100644 minivirt/domain_pb2_grpc.py delete mode 100644 minivirt/host.py delete mode 100644 minivirt/host_pb2.py delete mode 100644 minivirt/host_pb2_grpc.py delete mode 100644 minivirt/image.py delete mode 100644 minivirt/main.py delete mode 100644 minivirt/migrations.py delete mode 100644 minivirt/models.py delete mode 100644 minivirt/port_forwarding.py delete mode 100644 minivirt/port_forwarding_pb2.py delete mode 100644 minivirt/port_forwarding_pb2_grpc.py delete mode 100644 minivirt/route.py delete mode 100644 minivirt/route_pb2.py delete mode 100644 minivirt/route_pb2_grpc.py delete mode 100644 minivirt/utils.py delete mode 100644 minivirt/version.py delete mode 100644 minivirt/volume_pb2.py delete mode 100644 minivirt/volume_pb2_grpc.py delete mode 100644 protos/minivirt/controller.proto delete mode 100644 protos/minivirt/daemon.proto delete mode 100644 protos/minivirt/dns.proto delete mode 100644 protos/minivirt/domain.proto delete mode 100644 protos/minivirt/host.proto delete mode 100644 protos/minivirt/port_forwarding.proto delete mode 100644 protos/minivirt/route.proto delete mode 100644 protos/minivirt/volume.proto delete mode 100644 pyproject.toml rename virtuerl/rebar.config => rebar.config (100%) rename virtuerl/rebar.lock => rebar.lock (100%) delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt delete mode 100644 setup.py delete mode 100755 snap/hooks/configure delete mode 100644 snap/hooks/install delete mode 100755 snap/local/bin/bird-wrapper delete mode 100755 snap/local/bin/birdc-wrapper delete mode 100755 snap/local/bin/restvirt-controller delete mode 100755 snap/local/bin/restvirt-daemon delete mode 100755 snap/local/bin/restvirt-deregister delete mode 100755 snap/local/bin/restvirt-register delete mode 100755 snap/local/bin/unbound-wrapper delete mode 100644 snap/local/etc/bird/minivirt.conf delete mode 100644 snap/local/etc/unbound/minivirt.conf delete mode 100644 snap/snapcraft.yaml rename {virtuerl/src => src}/virtuerl.app.src (100%) rename {virtuerl/src => src}/virtuerl_api.erl (100%) rename {virtuerl/src => src}/virtuerl_app.erl (100%) rename {virtuerl/src => src}/virtuerl_ghac.erl (100%) rename {virtuerl/src => src}/virtuerl_img.erl (100%) rename {virtuerl/src => src}/virtuerl_ipam.erl (100%) rename {virtuerl/src => src}/virtuerl_mgt.erl (100%) rename {virtuerl/src => src}/virtuerl_net.erl (100%) rename {virtuerl/src => src}/virtuerl_pubsub.erl (100%) rename {virtuerl/src => src}/virtuerl_qemu.erl (100%) rename {virtuerl/src => src}/virtuerl_qmp.erl (100%) rename {virtuerl/src => src}/virtuerl_sup.erl (100%) rename {virtuerl/src => src}/virtuerl_ui.erl (100%) rename {virtuerl/src => src}/virtuerl_util.erl (100%) rename {virtuerl/src => src}/virtuerl_vnc.erl (100%) rename {virtuerl/src => src}/virtuerl_vnc_proxy.erl (100%) rename {virtuerl/test => test}/ipam.erl (100%) rename {virtuerl/test => test}/scheduler.erl (100%) rename {virtuerl/test => test}/virtuerl_SUITE.erl (100%) delete mode 100644 tests/integration/test_integration.py delete mode 100644 tests/unit/__init__.py delete mode 100644 tests/unit/conftest.py delete mode 100644 tests/unit/test_dns.py delete mode 100644 tests/unit/test_domain.py delete mode 100644 tests/unit/test_host.py delete mode 100644 tests/unit/test_image.py delete mode 100644 tests/unit/test_port_forwarding.py delete mode 100644 tests/unit/test_route.py delete mode 100644 virtuerl/.gitignore delete mode 100644 virtuerl/.idea/.gitignore delete mode 100644 virtuerl/.idea/codeStyles/Project.xml delete mode 100644 virtuerl/.idea/codeStyles/codeStyleConfig.xml delete mode 100644 virtuerl/.idea/modules.xml delete mode 100644 virtuerl/.idea/vcs.xml delete mode 100644 virtuerl/LICENSE.md delete mode 100644 virtuerl/README.md delete mode 100644 virtuerl/Vagrantfile delete mode 100644 virtuerl/bird.conf delete mode 100644 virtuerl/erlang_ls.config diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 4757721..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -venv/ -.pytest_cache/ -.idea/ -Dockerfile diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 79f04cc..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -ignore = E501,W503 -exclude = migrations,venv diff --git a/.gitignore b/.gitignore index 5638fa5..78647f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,25 @@ -#.idea/ -venv/ -.venv/ -__pycache__/ -*.snap -*.egg-info -*.sqlite3 +*.iml +.DS_Store +.vagrant/ +khepri*/ + +.rebar3 +_build +_checkouts +_vendor +.eunit +*.o +*.beam +*.plt +*.swp +*.swo +.erlang.cookie +ebin +log +erl_crash.dump +.rebar +logs +#.idea +#*.iml +rebar3.crashdump +*~ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0c1ae78..0000000 --- a/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -FROM python:3.9.7-slim-bullseye AS base -ENV PATH="/root/.local/bin:$PATH" -WORKDIR /app - - -FROM base AS base_build -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - libc-dev \ - pkg-config \ - libvirt-dev \ - git \ - && rm -rf /var/lib/apt/lists/* -COPY requirements.txt . -RUN pip install --user -r requirements.txt - - -FROM base_build as test_build -COPY requirements-dev.txt . -RUN pip install --user -r requirements-dev.txt - - -FROM base as base_run -RUN apt-get update && apt-get install -y --no-install-recommends \ - libvirt0 \ - iptables \ - libnftables1 \ - && rm -rf /var/lib/apt/lists/* - - -FROM base_run as test -COPY --from=test_build /root/.local /root/.local -COPY . . -ENTRYPOINT ["/usr/bin/env", "python3", "-m", "pytest"] -CMD ["tests"] - - -FROM base_run as default -LABEL org.opencontainers.image.source=https://github.com/verbit/restvirt -COPY --from=base_build /root/.local /root/.local -COPY . . -ENTRYPOINT ["/usr/bin/env", "python3", "main.py"] diff --git a/README.md b/README.md index c9f4625..8f86b0e 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,57 @@ -# RESTvirt +virtuerl +===== -Manage libvirt through a REST API. +An OTP application -# Installation - -```shell -apt install --no-install-recommends dnsmasq-base libvirt-daemon-system qemu-kvm qemu-utils -snap install minivirt -sudo snap connect minivirt:network-control -sudo snap connect minivirt:firewall-control -sudo snap connect minivirt:libvirt +# Required packages +```sh +sudo apt install ovmf swtpm ``` -## Getting Started - -```shell -git clone git@github.com:verbit/restvirt.git -cd restvirt - -apt install python3-dev libvirt-dev -pip install -r requirements.txt +# Windows Guests + +## Disable boot prompt +```sh +sudo mount -o loop Win11_23H2_EnglishInternational_x64v2.iso /mnt/win + +genisoimage \ + --allow-limited-size \ + -no-emul-boot \ + -b "boot/etfsboot.com" \ + -boot-load-seg 0 \ + -boot-load-size 8 \ + -eltorito-alt-boot \ + -no-emul-boot \ + -e "efi/microsoft/boot/efisys_noprompt.bin" \ + -boot-load-size 1 \ + -iso-level 4 \ + -udf \ + -o "win.iso" \ + /mnt/win/ +``` -mkdir /etc/restvirt +# Running -# start controller -python main.py controller +On the server -#start daemon -apt install libvirt-daemon-system -python main.py daemon +Make sure IP forwarding is enabled (`/etc/sysctl.conf`) ``` - -## Code Generation -```shell -python -m grpc_tools.protoc --python_out=. --grpc_python_out=. -Iprotos/ protos/minivirt/*.proto +# Uncomment the next line to enable packet forwarding for IPv4 +net.ipv4.ip_forward=1 +# Uncomment the next line to enable packet forwarding for IPv6 +net.ipv6.conf.all.forwarding=1 ``` +Run `sysctl -w` to commit changes. -## Known Issues +```sh +sudo -s ./erts-13.1.5/bin/erl -mode embedded -boot releases/0.7.0+build.61.ref8fc0b7e/start -config releases/0.7.0+build.61.ref8fc0b7e/sys.config -proto_dist inet6_tcp -name verbit@verbit.in-berlin.de -setcookie abcdef +``` -* AppArmor - * https://ubuntu.com/server/docs/virtualization-libvirt - * https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1677398 +Locally +```sh +rebar3 compile +erl -name moi -proto_dist inet6_tcp -setcookie abcdef -pa _build/default/lib/*/ebin -hidden +(moi@t460s.lan)1> net_adm:ping('virtuerl@a.in6.dev'). +pong +(moi@t460s.lan)2> virtuerl_ui:start('virtuerl@a.in6.dev'). +``` diff --git a/virtuerl/config/sys.config b/config/sys.config similarity index 100% rename from virtuerl/config/sys.config rename to config/sys.config diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml deleted file mode 100644 index 22a1621..0000000 --- a/examples/docker-compose.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3.3" -services: - web: - image: ghcr.io/verbit/restvirt:latest - command: - - -b - - :8093 - - --server-cert - - /etc/restvirt/pki/server.crt - - --server-key - - /etc/restvirt/pki/server.key - - --client-ca-cert - - /etc/restvirt/pki/ca.crt - cap_add: - - NET_ADMIN - - NET_RAW - network_mode: host - volumes: - - "/etc/restvirt:/etc/restvirt" - - "/data/restvirt:/data/restvirt" - - "/var/run/libvirt:/var/run/libvirt" diff --git a/virtuerl/hack/repack b/hack/repack similarity index 100% rename from virtuerl/hack/repack rename to hack/repack diff --git a/minivirt/__init__.py b/minivirt/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/minivirt/controller.py b/minivirt/controller.py deleted file mode 100644 index 1aacd5a..0000000 --- a/minivirt/controller.py +++ /dev/null @@ -1,193 +0,0 @@ -import grpc -from google.protobuf import empty_pb2 -from grpc import StatusCode - -from minivirt import ( - controller_pb2_grpc, - daemon_pb2, - daemon_pb2_grpc, - dns_pb2, - dns_pb2_grpc, - route_pb2, - route_pb2_grpc, -) -from minivirt.host import HostController -from minivirt.models import DNSRecord -from minivirt.route import GenericRouteController, GenericRouteTableController, SyncEventHandler - - -class ControllerSyncHandler(SyncEventHandler): - def __init__(self, host_controller): - self.host_controller = host_controller - - def handle_sync(self, session): - channels = self.host_controller.channels() - for channel in channels: - client = daemon_pb2_grpc.DaemonServiceStub(channel) - client.SyncRoutes(daemon_pb2.SyncRoutesRequest()) - - -class Controller( - controller_pb2_grpc.ControllerServiceServicer, - dns_pb2_grpc.DNSServicer, - route_pb2_grpc.RouteServiceServicer, -): - def __init__(self, session_factory, host_controller: HostController, dns_controller): - self.session_factory = session_factory - self.host_controller = host_controller - self.dns_controller = dns_controller - sync_handler = ControllerSyncHandler(host_controller) - self.route_table_controller = GenericRouteTableController(session_factory, sync_handler) - self.route_controller = GenericRouteController(session_factory, sync_handler) - self.channel_cache = {} - - def _get_daemon_client(self, hostname=None): - if not hostname: - hostname = "default" - return daemon_pb2_grpc.DaemonServiceStub(self.host_controller.channel(hostname)) - - def GetDNSRecord(self, request, context): - record = self.dns_controller.record(request.name, request.type) - if record is None: - context.set_code(StatusCode.NOT_FOUND) - return empty_pb2.Empty() - return dns_pb2.DNSRecord( - name=record.name, - type=record.type, - ttl=record.ttl, - records=record.records, - ) - - def ListDNSRecords(self, request, context): - return dns_pb2.ListDNSRecordsResponse( - dns_records=[ - dns_pb2.DNSRecord( - name=record.name, - type=record.type, - ttl=record.ttl, - records=record.records, - ) - for record in self.dns_controller.records() - ] - ) - - def PutDNSRecord(self, request, context): - record = request.dns_record - self.dns_controller.set( - DNSRecord( - name=record.name, - type=record.type, - ttl=record.ttl, - records=record.records, - ) - ) - return record - - def DeleteDNSRecord(self, request, context): - self.dns_controller.remove(request.name, request.type) - return empty_pb2.Empty() - - def GetRouteTable(self, request, context): - table = self.route_table_controller.route_table(request.id) - if table is None: - context.set_code(StatusCode.NOT_FOUND) - return empty_pb2.Empty() - - return route_pb2.RouteTable( - id=table.id, - name=table.name, - ) - - def ListRouteTables(self, request, context): - tables = self.route_table_controller.route_tables() - - return route_pb2.ListRouteTablesResponse( - route_tables=[ - route_pb2.RouteTable( - id=table.id, - name=table.name, - ) - for table in tables - ] - ) - - def CreateRouteTable(self, request, context): - table = self.route_table_controller.create_route_table(request.route_table) - return table - - def DeleteRouteTable(self, request, context): - self.route_table_controller.remove_route_table(request.id) - return empty_pb2.Empty() - - def GetRoute(self, request, context): - route = self.route_controller.route(request.route_table_id, request.destination) - return route_pb2.Route( - route_table_id=route.route_table_id, - destination=route.destination, - gateways=route.gateways, - ) - - def ListRoutes(self, request, context): - routes = self.route_controller.routes(request.route_table_id) - - return route_pb2.ListRoutesResponse( - routes=[ - route_pb2.Route( - route_table_id=route.route_table_id, - destination=route.destination, - gateways=route.gateways, - ) - for route in routes - ] - ) - - def PutRoute(self, request, context): - route = self.route_controller.put_route(request.route) - return route - - def DeleteRoute(self, request, context): - self.route_controller.remove_route(request.route_table_id, request.destination) - return empty_pb2.Empty() - - def SyncRoutes(self, request, context): - self.route_table_controller.sync() - self.route_controller.sync() - return empty_pb2.Empty() - - def Sync(self, request, context): - # TODO: implement or remove - return super().Sync(request, context) - - -def monkeypatch_controller(): - cls = Controller - super_methods = { - getattr(base, a) for base in cls.__bases__ for a in dir(base) if not a.startswith("__") - } - sub_methods = {getattr(cls, a) for a in dir(cls) if not a.startswith("__")} - - for method in super_methods & sub_methods: - method_name = method.__name__ - - def create_target_method(method_name): - def target(self, request, context): - client = self._get_daemon_client(request.host) - try: - to_call = getattr(client, method_name) - if isinstance(to_call, grpc.UnaryUnaryMultiCallable): - return to_call(request) - elif isinstance(to_call, grpc.UnaryStreamMultiCallable): - return (chunk for chunk in to_call(request)) - else: - assert False # TODO - except grpc.RpcError as e: - context.set_code(e.code()) - context.set_details(e.details()) - return empty_pb2.Empty() - - return target - - setattr(cls, method_name, create_target_method(method_name)) - - -monkeypatch_controller() diff --git a/minivirt/controller_pb2.py b/minivirt/controller_pb2.py deleted file mode 100644 index 83d0cfa..0000000 --- a/minivirt/controller_pb2.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/controller.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import daemon_pb2 as minivirt_dot_daemon__pb2 -from minivirt import domain_pb2 as minivirt_dot_domain__pb2 -from minivirt import volume_pb2 as minivirt_dot_volume__pb2 -from minivirt import port_forwarding_pb2 as minivirt_dot_port__forwarding__pb2 -from minivirt import dns_pb2 as minivirt_dot_dns__pb2 -from minivirt import route_pb2 as minivirt_dot_route__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19minivirt/controller.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15minivirt/daemon.proto\x1a\x15minivirt/domain.proto\x1a\x15minivirt/volume.proto\x1a\x1eminivirt/port_forwarding.proto\x1a\x12minivirt/dns.proto\x1a\x14minivirt/route.proto2\xce\x11\n\x11\x43ontrollerService\x12\x32\n\x0cGetDNSRecord\x12\x14.DNSRecordIdentifier\x1a\n.DNSRecord\"\x00\x12\x43\n\x0eListDNSRecords\x12\x16.ListDNSRecordsRequest\x1a\x17.ListDNSRecordsResponse\"\x00\x12\x32\n\x0cPutDNSRecord\x12\x14.PutDNSRecordRequest\x1a\n.DNSRecord\"\x00\x12\x41\n\x0f\x44\x65leteDNSRecord\x12\x14.DNSRecordIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12,\n\nGetNetwork\x12\x12.GetNetworkRequest\x1a\x08.Network\"\x00\x12=\n\x0cListNetworks\x12\x14.ListNetworksRequest\x1a\x15.ListNetworksResponse\"\x00\x12\x32\n\rCreateNetwork\x12\x15.CreateNetworkRequest\x1a\x08.Network\"\x00\x12@\n\rDeleteNetwork\x12\x15.DeleteNetworkRequest\x1a\x16.google.protobuf.Empty\"\x00\x12<\n\x0bStartDomain\x12\x13.StartDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12:\n\nStopDomain\x12\x12.StopDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12)\n\tGetDomain\x12\x11.GetDomainRequest\x1a\x07.Domain\"\x00\x12:\n\x0bListDomains\x12\x13.ListDomainsRequest\x1a\x14.ListDomainsResponse\"\x00\x12/\n\x0c\x43reateDomain\x12\x14.CreateDomainRequest\x1a\x07.Domain\"\x00\x12>\n\x0c\x44\x65leteDomain\x12\x14.DeleteDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12\x37\n\rDownloadImage\x12\x15.DownloadImageRequest\x1a\x0b.ImageChunk\"\x00\x30\x01\x12)\n\tGetVolume\x12\x11.GetVolumeRequest\x1a\x07.Volume\"\x00\x12:\n\x0bListVolumes\x12\x13.ListVolumesRequest\x1a\x14.ListVolumesResponse\"\x00\x12/\n\x0c\x43reateVolume\x12\x14.CreateVolumeRequest\x1a\x07.Volume\"\x00\x12/\n\x0cUpdateVolume\x12\x14.UpdateVolumeRequest\x1a\x07.Volume\"\x00\x12>\n\x0c\x44\x65leteVolume\x12\x14.DeleteVolumeRequest\x1a\x16.google.protobuf.Empty\"\x00\x12X\n\x15ListVolumeAttachments\x12\x1d.ListVolumeAttachmentsRequest\x1a\x1e.ListVolumeAttachmentsResponse\"\x00\x12G\n\x13GetVolumeAttachment\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12@\n\x0c\x41ttachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12\x45\n\x0c\x44\x65tachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12\x41\n\x11GetPortForwarding\x12\x19.PortForwardingIdentifier\x1a\x0f.PortForwarding\"\x00\x12R\n\x13ListPortForwardings\x12\x1b.ListPortForwardingsRequest\x1a\x1c.ListPortForwardingsResponse\"\x00\x12\x41\n\x11PutPortForwarding\x12\x19.PutPortForwardingRequest\x1a\x0f.PortForwarding\"\x00\x12K\n\x14\x44\x65letePortForwarding\x12\x19.PortForwardingIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12\x35\n\rGetRouteTable\x12\x15.RouteTableIdentifier\x1a\x0b.RouteTable\"\x00\x12\x46\n\x0fListRouteTables\x12\x17.ListRouteTablesRequest\x1a\x18.ListRouteTablesResponse\"\x00\x12;\n\x10\x43reateRouteTable\x12\x18.CreateRouteTableRequest\x1a\x0b.RouteTable\"\x00\x12\x43\n\x10\x44\x65leteRouteTable\x12\x15.RouteTableIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12&\n\x08GetRoute\x12\x10.RouteIdentifier\x1a\x06.Route\"\x00\x12\x37\n\nListRoutes\x12\x12.ListRoutesRequest\x1a\x13.ListRoutesResponse\"\x00\x12&\n\x08PutRoute\x12\x10.PutRouteRequest\x1a\x06.Route\"\x00\x12\x39\n\x0b\x44\x65leteRoute\x12\x10.RouteIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12:\n\nSyncRoutes\x12\x12.SyncRoutesRequest\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.controller_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _CONTROLLERSERVICE._serialized_start=202 - _CONTROLLERSERVICE._serialized_end=2456 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/controller_pb2_grpc.py b/minivirt/controller_pb2_grpc.py deleted file mode 100644 index a4fab8c..0000000 --- a/minivirt/controller_pb2_grpc.py +++ /dev/null @@ -1,1260 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import daemon_pb2 as minivirt_dot_daemon__pb2 -from minivirt import dns_pb2 as minivirt_dot_dns__pb2 -from minivirt import domain_pb2 as minivirt_dot_domain__pb2 -from minivirt import port_forwarding_pb2 as minivirt_dot_port__forwarding__pb2 -from minivirt import route_pb2 as minivirt_dot_route__pb2 -from minivirt import volume_pb2 as minivirt_dot_volume__pb2 - - -class ControllerServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetDNSRecord = channel.unary_unary( - '/ControllerService/GetDNSRecord', - request_serializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.DNSRecord.FromString, - ) - self.ListDNSRecords = channel.unary_unary( - '/ControllerService/ListDNSRecords', - request_serializer=minivirt_dot_dns__pb2.ListDNSRecordsRequest.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.ListDNSRecordsResponse.FromString, - ) - self.PutDNSRecord = channel.unary_unary( - '/ControllerService/PutDNSRecord', - request_serializer=minivirt_dot_dns__pb2.PutDNSRecordRequest.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.DNSRecord.FromString, - ) - self.DeleteDNSRecord = channel.unary_unary( - '/ControllerService/DeleteDNSRecord', - request_serializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetNetwork = channel.unary_unary( - '/ControllerService/GetNetwork', - request_serializer=minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.ListNetworks = channel.unary_unary( - '/ControllerService/ListNetworks', - request_serializer=minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - ) - self.CreateNetwork = channel.unary_unary( - '/ControllerService/CreateNetwork', - request_serializer=minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.DeleteNetwork = channel.unary_unary( - '/ControllerService/DeleteNetwork', - request_serializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.StartDomain = channel.unary_unary( - '/ControllerService/StartDomain', - request_serializer=minivirt_dot_domain__pb2.StartDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.StopDomain = channel.unary_unary( - '/ControllerService/StopDomain', - request_serializer=minivirt_dot_domain__pb2.StopDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetDomain = channel.unary_unary( - '/ControllerService/GetDomain', - request_serializer=minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.ListDomains = channel.unary_unary( - '/ControllerService/ListDomains', - request_serializer=minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - ) - self.CreateDomain = channel.unary_unary( - '/ControllerService/CreateDomain', - request_serializer=minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.DeleteDomain = channel.unary_unary( - '/ControllerService/DeleteDomain', - request_serializer=minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.DownloadImage = channel.unary_stream( - '/ControllerService/DownloadImage', - request_serializer=minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ImageChunk.FromString, - ) - self.GetVolume = channel.unary_unary( - '/ControllerService/GetVolume', - request_serializer=minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.ListVolumes = channel.unary_unary( - '/ControllerService/ListVolumes', - request_serializer=minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - ) - self.CreateVolume = channel.unary_unary( - '/ControllerService/CreateVolume', - request_serializer=minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.UpdateVolume = channel.unary_unary( - '/ControllerService/UpdateVolume', - request_serializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.DeleteVolume = channel.unary_unary( - '/ControllerService/DeleteVolume', - request_serializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.ListVolumeAttachments = channel.unary_unary( - '/ControllerService/ListVolumeAttachments', - request_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - ) - self.GetVolumeAttachment = channel.unary_unary( - '/ControllerService/GetVolumeAttachment', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.AttachVolume = channel.unary_unary( - '/ControllerService/AttachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.DetachVolume = channel.unary_unary( - '/ControllerService/DetachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetPortForwarding = channel.unary_unary( - '/ControllerService/GetPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.ListPortForwardings = channel.unary_unary( - '/ControllerService/ListPortForwardings', - request_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - ) - self.PutPortForwarding = channel.unary_unary( - '/ControllerService/PutPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.DeletePortForwarding = channel.unary_unary( - '/ControllerService/DeletePortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetRouteTable = channel.unary_unary( - '/ControllerService/GetRouteTable', - request_serializer=minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.RouteTable.FromString, - ) - self.ListRouteTables = channel.unary_unary( - '/ControllerService/ListRouteTables', - request_serializer=minivirt_dot_route__pb2.ListRouteTablesRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.ListRouteTablesResponse.FromString, - ) - self.CreateRouteTable = channel.unary_unary( - '/ControllerService/CreateRouteTable', - request_serializer=minivirt_dot_route__pb2.CreateRouteTableRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.RouteTable.FromString, - ) - self.DeleteRouteTable = channel.unary_unary( - '/ControllerService/DeleteRouteTable', - request_serializer=minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetRoute = channel.unary_unary( - '/ControllerService/GetRoute', - request_serializer=minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.Route.FromString, - ) - self.ListRoutes = channel.unary_unary( - '/ControllerService/ListRoutes', - request_serializer=minivirt_dot_route__pb2.ListRoutesRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.ListRoutesResponse.FromString, - ) - self.PutRoute = channel.unary_unary( - '/ControllerService/PutRoute', - request_serializer=minivirt_dot_route__pb2.PutRouteRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.Route.FromString, - ) - self.DeleteRoute = channel.unary_unary( - '/ControllerService/DeleteRoute', - request_serializer=minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.SyncRoutes = channel.unary_unary( - '/ControllerService/SyncRoutes', - request_serializer=minivirt_dot_daemon__pb2.SyncRoutesRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class ControllerServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListDNSRecords(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListNetworks(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StartDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StopDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListDomains(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DownloadImage(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UpdateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumeAttachments(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetVolumeAttachment(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def AttachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DetachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListPortForwardings(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeletePortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListRouteTables(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListRoutes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def SyncRoutes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_ControllerServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.GetDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.FromString, - response_serializer=minivirt_dot_dns__pb2.DNSRecord.SerializeToString, - ), - 'ListDNSRecords': grpc.unary_unary_rpc_method_handler( - servicer.ListDNSRecords, - request_deserializer=minivirt_dot_dns__pb2.ListDNSRecordsRequest.FromString, - response_serializer=minivirt_dot_dns__pb2.ListDNSRecordsResponse.SerializeToString, - ), - 'PutDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.PutDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.PutDNSRecordRequest.FromString, - response_serializer=minivirt_dot_dns__pb2.DNSRecord.SerializeToString, - ), - 'DeleteDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.DeleteDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetNetwork': grpc.unary_unary_rpc_method_handler( - servicer.GetNetwork, - request_deserializer=minivirt_dot_domain__pb2.GetNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'ListNetworks': grpc.unary_unary_rpc_method_handler( - servicer.ListNetworks, - request_deserializer=minivirt_dot_domain__pb2.ListNetworksRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListNetworksResponse.SerializeToString, - ), - 'CreateNetwork': grpc.unary_unary_rpc_method_handler( - servicer.CreateNetwork, - request_deserializer=minivirt_dot_domain__pb2.CreateNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'DeleteNetwork': grpc.unary_unary_rpc_method_handler( - servicer.DeleteNetwork, - request_deserializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'StartDomain': grpc.unary_unary_rpc_method_handler( - servicer.StartDomain, - request_deserializer=minivirt_dot_domain__pb2.StartDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'StopDomain': grpc.unary_unary_rpc_method_handler( - servicer.StopDomain, - request_deserializer=minivirt_dot_domain__pb2.StopDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetDomain': grpc.unary_unary_rpc_method_handler( - servicer.GetDomain, - request_deserializer=minivirt_dot_domain__pb2.GetDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'ListDomains': grpc.unary_unary_rpc_method_handler( - servicer.ListDomains, - request_deserializer=minivirt_dot_domain__pb2.ListDomainsRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListDomainsResponse.SerializeToString, - ), - 'CreateDomain': grpc.unary_unary_rpc_method_handler( - servicer.CreateDomain, - request_deserializer=minivirt_dot_domain__pb2.CreateDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'DeleteDomain': grpc.unary_unary_rpc_method_handler( - servicer.DeleteDomain, - request_deserializer=minivirt_dot_domain__pb2.DeleteDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'DownloadImage': grpc.unary_stream_rpc_method_handler( - servicer.DownloadImage, - request_deserializer=minivirt_dot_domain__pb2.DownloadImageRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ImageChunk.SerializeToString, - ), - 'GetVolume': grpc.unary_unary_rpc_method_handler( - servicer.GetVolume, - request_deserializer=minivirt_dot_volume__pb2.GetVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'ListVolumes': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumes, - request_deserializer=minivirt_dot_volume__pb2.ListVolumesRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumesResponse.SerializeToString, - ), - 'CreateVolume': grpc.unary_unary_rpc_method_handler( - servicer.CreateVolume, - request_deserializer=minivirt_dot_volume__pb2.CreateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'UpdateVolume': grpc.unary_unary_rpc_method_handler( - servicer.UpdateVolume, - request_deserializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'DeleteVolume': grpc.unary_unary_rpc_method_handler( - servicer.DeleteVolume, - request_deserializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'ListVolumeAttachments': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumeAttachments, - request_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.SerializeToString, - ), - 'GetVolumeAttachment': grpc.unary_unary_rpc_method_handler( - servicer.GetVolumeAttachment, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'AttachVolume': grpc.unary_unary_rpc_method_handler( - servicer.AttachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'DetachVolume': grpc.unary_unary_rpc_method_handler( - servicer.DetachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.GetPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'ListPortForwardings': grpc.unary_unary_rpc_method_handler( - servicer.ListPortForwardings, - request_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.SerializeToString, - ), - 'PutPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.PutPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'DeletePortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.DeletePortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.GetRouteTable, - request_deserializer=minivirt_dot_route__pb2.RouteTableIdentifier.FromString, - response_serializer=minivirt_dot_route__pb2.RouteTable.SerializeToString, - ), - 'ListRouteTables': grpc.unary_unary_rpc_method_handler( - servicer.ListRouteTables, - request_deserializer=minivirt_dot_route__pb2.ListRouteTablesRequest.FromString, - response_serializer=minivirt_dot_route__pb2.ListRouteTablesResponse.SerializeToString, - ), - 'CreateRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.CreateRouteTable, - request_deserializer=minivirt_dot_route__pb2.CreateRouteTableRequest.FromString, - response_serializer=minivirt_dot_route__pb2.RouteTable.SerializeToString, - ), - 'DeleteRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.DeleteRouteTable, - request_deserializer=minivirt_dot_route__pb2.RouteTableIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetRoute': grpc.unary_unary_rpc_method_handler( - servicer.GetRoute, - request_deserializer=minivirt_dot_route__pb2.RouteIdentifier.FromString, - response_serializer=minivirt_dot_route__pb2.Route.SerializeToString, - ), - 'ListRoutes': grpc.unary_unary_rpc_method_handler( - servicer.ListRoutes, - request_deserializer=minivirt_dot_route__pb2.ListRoutesRequest.FromString, - response_serializer=minivirt_dot_route__pb2.ListRoutesResponse.SerializeToString, - ), - 'PutRoute': grpc.unary_unary_rpc_method_handler( - servicer.PutRoute, - request_deserializer=minivirt_dot_route__pb2.PutRouteRequest.FromString, - response_serializer=minivirt_dot_route__pb2.Route.SerializeToString, - ), - 'DeleteRoute': grpc.unary_unary_rpc_method_handler( - servicer.DeleteRoute, - request_deserializer=minivirt_dot_route__pb2.RouteIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'SyncRoutes': grpc.unary_unary_rpc_method_handler( - servicer.SyncRoutes, - request_deserializer=minivirt_dot_daemon__pb2.SyncRoutesRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'ControllerService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class ControllerService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetDNSRecord', - minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - minivirt_dot_dns__pb2.DNSRecord.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListDNSRecords(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListDNSRecords', - minivirt_dot_dns__pb2.ListDNSRecordsRequest.SerializeToString, - minivirt_dot_dns__pb2.ListDNSRecordsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/PutDNSRecord', - minivirt_dot_dns__pb2.PutDNSRecordRequest.SerializeToString, - minivirt_dot_dns__pb2.DNSRecord.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteDNSRecord', - minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetNetwork', - minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListNetworks(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListNetworks', - minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/CreateNetwork', - minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteNetwork', - minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def StartDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/StartDomain', - minivirt_dot_domain__pb2.StartDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def StopDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/StopDomain', - minivirt_dot_domain__pb2.StopDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetDomain', - minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListDomains(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListDomains', - minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/CreateDomain', - minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteDomain', - minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DownloadImage(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream(request, target, '/ControllerService/DownloadImage', - minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - minivirt_dot_domain__pb2.ImageChunk.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetVolume', - minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListVolumes', - minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/CreateVolume', - minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def UpdateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/UpdateVolume', - minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteVolume', - minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumeAttachments(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListVolumeAttachments', - minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetVolumeAttachment(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetVolumeAttachment', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def AttachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/AttachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DetachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DetachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetPortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListPortForwardings(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListPortForwardings', - minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/PutPortForwarding', - minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeletePortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeletePortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetRouteTable', - minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - minivirt_dot_route__pb2.RouteTable.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListRouteTables(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListRouteTables', - minivirt_dot_route__pb2.ListRouteTablesRequest.SerializeToString, - minivirt_dot_route__pb2.ListRouteTablesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/CreateRouteTable', - minivirt_dot_route__pb2.CreateRouteTableRequest.SerializeToString, - minivirt_dot_route__pb2.RouteTable.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteRouteTable', - minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/GetRoute', - minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - minivirt_dot_route__pb2.Route.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListRoutes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/ListRoutes', - minivirt_dot_route__pb2.ListRoutesRequest.SerializeToString, - minivirt_dot_route__pb2.ListRoutesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/PutRoute', - minivirt_dot_route__pb2.PutRouteRequest.SerializeToString, - minivirt_dot_route__pb2.Route.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/DeleteRoute', - minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def SyncRoutes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ControllerService/SyncRoutes', - minivirt_dot_daemon__pb2.SyncRoutesRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/daemon.py b/minivirt/daemon.py deleted file mode 100644 index 696fcc1..0000000 --- a/minivirt/daemon.py +++ /dev/null @@ -1,894 +0,0 @@ -import ipaddress -import os -import re -import string -import threading -import uuid -from datetime import datetime, timezone - -import libvirt -import requests -import xmltodict -from google.protobuf import empty_pb2, timestamp_pb2 -from grpc import StatusCode -from pyroute2 import IPRoute -from pyroute2.netlink.rtnl import rtypes -from requests.exceptions import ConnectionError, HTTPError -from sqlalchemy import delete, select - -from minivirt import ( - controller_pb2_grpc, - daemon_pb2_grpc, - domain_pb2, - port_forwarding_pb2, - route_pb2, - volume_pb2, -) -from minivirt.image import create_cloud_config_image -from minivirt.models import Domain, PortForwarding - - -def libvirt_state_to_string(state): - if state == libvirt.VIR_DOMAIN_NOSTATE: - return "NOSTATE" - elif state == libvirt.VIR_DOMAIN_RUNNING: - return "RUNNING" - elif state == libvirt.VIR_DOMAIN_BLOCKED: - return "BLOCKED" - elif state == libvirt.VIR_DOMAIN_PAUSED: - return "PAUSED" - elif state == libvirt.VIR_DOMAIN_SHUTDOWN: - return "SHUTDOWN" - elif state == libvirt.VIR_DOMAIN_CRASHED: - return "CRASHED" - elif state == libvirt.VIR_DOMAIN_PMSUSPENDED: - return "PMSUSPENDED" - elif state == libvirt.VIR_DOMAIN_SHUTOFF: - return "SHUTOFF" - return "UNKNOWN" - - -def domain_to_dict(domain): - domain_dict = xmltodict.parse(domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)) - d = domain_dict["domain"] - res = { - "uuid": d["uuid"], - "name": d["name"], - "vcpu": int(d["vcpu"]["#text"]), - "memory": int(d["memory"]["#text"]) // 1024, - "nested_virtualization": d["cpu"]["@mode"] == "host-model", - } - try: - res["network"] = d["devices"]["interface"]["source"]["@network"] - except: - pass - try: # FIXME: once all have create metadata, remove this try/catch - dt = datetime.fromisoformat(d["metadata"]["restvirt:metadata"]["created"]) - res["created_at"] = timestamp_pb2.Timestamp( - seconds=int(dt.timestamp()) - ) # we don't need sub-second precision - except Exception as e: - print(e) - return res - - -def _volume_to_dict(vol): - _, cap, _ = vol.info() - name = vol.name() - return { - "id": name, - "name": name, - "size": cap, - } - - -def _get_attachments(domain): - domain_dict = xmltodict.parse(domain.XMLDesc()) - disks = domain_dict["domain"]["devices"]["disk"] - volume_ids = [ - d["alias"]["@name"][3:] - for d in disks - if d["@device"] == "disk" and d["alias"]["@name"].startswith("ua-") - ] - attachments = [ - { - "volume_id": vid, - "disk_address": _disk_address(domain_dict, vid), - } - for vid in volume_ids - ] - - return attachments - - -def _get_all_attachments(domains, vol): - vol_id = vol.name() - attachments = [(domain, _get_attachments(domain)) for domain in domains] - attachments = [(d, da) for d, das in attachments for da in das] - filtered_domains = [(d, da) for (d, da) in attachments if da["volume_id"] == vol_id] - filtered_domains = [ - {"domain_id": d.UUIDString(), "disk_address": da["disk_address"]} - for d, da in filtered_domains - ] - return filtered_domains - - -def _disk_address(domain_dict, volume_id): - disks = domain_dict["domain"]["devices"]["disk"] - - da = [d["address"] for d in disks if d["alias"]["@name"] == f"ua-{volume_id}"][0] - daddr = [int(da[f"@{k}"], 16) for k in ["domain", "bus", "slot", "function"]] - return f"{da['@type']}-{daddr[0]:04x}:{daddr[1]:02x}:{daddr[2]:02x}.{daddr[3]:x}" - - -def disk_address(domain, volume_id): - domain_dict = xmltodict.parse(domain.XMLDesc()) - return _disk_address(domain_dict, volume_id) - - -class IPRouteTableSynchronizer: - id_range_min, id_range_max = 30069, 30169 - - def __init__(self): - self.lock = threading.Lock() - - def handle_sync(self, client: controller_pb2_grpc.ControllerServiceStub): - with self.lock, IPRoute() as ip: - tables = client.ListRouteTables(route_pb2.ListRouteTablesRequest()).route_tables - table_ids = {t.id for t in tables} - - def filt(r): - prio = r.get_attr("FRA_PRIORITY") - return prio is not None and self.id_range_min <= prio <= self.id_range_max - - rules = filter(filt, ip.get_rules()) - rules = {r.get_attr("FRA_PRIORITY"): r for r in rules} - - # step 1: delete tables not in conf - for prio in rules: - if prio not in table_ids: - ip.rule("del", priority=prio) - - # step 2: update tables - # TODO: this is broken - for table in tables: - if table.id not in rules or rules[table.id]["table"] != table.id: - try: - ip.rule("del", priority=table.id) - except: - pass - ip.rule( - "add", - priority=table.id, - table=table.id, - ) - - -# TODO: RouteTableController -# try: -# # FIXME: make "virbr0" configurable -# ip.rule( -# "add", table=TABLE_ID, priority=30069, iifname="virbr0" -# ) # FIXME: check if rule identical -# except NetlinkError as e: -# if e.code != 17: # 17 = rule already exists -# raise e - - -class IPRouteSynchronizer: - id_range_min, id_range_max = 30069, 30169 - - def __init__(self): - self.lock = threading.Lock() - - def get_ip_routes(self, ip): - filtered_routes = {} - for r in ip.get_routes(): - table_id = r.get_attr("RTA_TABLE") - if not self.id_range_min <= table_id < self.id_range_max: - continue - if r["family"] != 2 or r["type"] != rtypes["RTN_UNICAST"]: - continue - dst = r.get_attr("RTA_DST") - if dst is None: - continue - dstnet = f"{dst}/{r['dst_len']}" - addr = ipaddress.ip_network(dstnet) - - gateway = r.get_attr("RTA_GATEWAY") - if gateway is not None: - gateways = [gateway] - else: - routes = r.get_attr("RTA_MULTIPATH") - gateways = [r.get_attr("RTA_GATEWAY") for r in routes] - filtered_routes[addr] = (table_id, {ipaddress.ip_address(gw) for gw in gateways}) - - return filtered_routes - - def remove_ip_route(self, ip, table_id, dst): - ip.route("del", table=table_id, dst=str(dst)) - - def put_ip_route(self, ip, table_id, dst, gws): - try: - ip.route("del", table=table_id, dst=str(dst)) - except: - pass - ip.route( - "add", - table=table_id, - dst=str(dst), - multipath=[{"gateway": str(gw)} for gw in gws], - ) - - def handle_sync(self, client: controller_pb2_grpc.ControllerServiceStub): - with self.lock, IPRoute() as ip: - tables = client.ListRouteTables(route_pb2.ListRouteTablesRequest()).route_tables - routes = [ - client.ListRoutes(route_pb2.ListRoutesRequest(route_table_id=table.id)).routes - for table in tables - ] - routes = [r for rs in routes for r in rs] - routes = { - ipaddress.IPv4Network(route.destination): ( - route.route_table_id, - {ipaddress.IPv4Address(gw) for gw in route.gateways}, - ) - for route in routes - } - - filtered_routes = self.get_ip_routes(ip) - - # step 1: delete routes not in conf - for dst, (tid, gws) in filtered_routes.items(): - if dst not in routes: - self.remove_ip_route(ip, tid, dst) - - # step 2: update routes - for dst, (tid, gws) in routes.items(): - if dst not in filtered_routes or filtered_routes[dst][1] != gws: - self.put_ip_route(ip, tid, dst, gws) - - -def create_storage_pool(conn, name, pool_dir, location=None): - if location is None: - location = name - - try: - conn.storagePoolLookupByName(name) - except libvirt.libvirtError as e: - if e.get_error_code() == libvirt.VIR_ERR_NO_STORAGE_POOL: - pool = conn.storagePoolDefineXML( - f""" - {name} - - {os.path.join(pool_dir, location)} - - """ - ) - pool.build() - pool.create() - else: - raise e - - -def get_root_volume(conn, domain_name): - try: - pool = conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(f"{domain_name}-root.qcow2") - except: - # FIXME: can be removed once not in use - pool = conn.storagePoolLookupByName("restvirtimages") - vol = pool.storageVolLookupByName(f"{domain_name}-root.qcow2") - return vol - - -def _network_prefix(net_elem): - # FIXME: remove/simplify me, once all network use prefix - if "@netmask" in net_elem: - return ipaddress.ip_network("0.0.0.0/" + net_elem["@netmask"]).prefixlen - return net_elem["@prefix"] - - -def _network_to_pb(net): - net_dict = xmltodict.parse(net.XMLDesc(), force_list=("ip",))["network"] - cidr6 = "" - if len(net_dict["ip"]) > 1: - cidr6 = str( - ipaddress.ip_network( - f'{net_dict["ip"][1]["@address"]}/{_network_prefix(net_dict["ip"][1])}', - strict=False, - ) - ) - return domain_pb2.Network( - uuid=net_dict["uuid"], - name=net_dict["name"], - cidr=str( - ipaddress.ip_network( - f'{net_dict["ip"][0]["@address"]}/{_network_prefix(net_dict["ip"][0])}', - strict=False, - ) - ), - cidr6=cidr6, - ) - - -class DaemonService(daemon_pb2_grpc.DaemonServiceServicer): - def __init__( - self, session_factory, port_fwd_sync_handler, controller_channel, pool_dir="/data/restvirt" - ): - self.session_factory = session_factory - self.port_fwd_sync_handler = port_fwd_sync_handler - self.controller = controller_pb2_grpc.ControllerServiceStub(controller_channel) - - self.tables_synchronizer = IPRouteTableSynchronizer() - self.routes_synchronizer = IPRouteSynchronizer() - - self.conn = libvirt.open("qemu:///system?socket=/var/run/libvirt/libvirt-sock") - - self.lock = threading.Lock() - - create_storage_pool(self.conn, "restvirtimages", pool_dir, "images") - create_storage_pool(self.conn, "volumes", pool_dir) - - def GetNetwork(self, request, context): - net = self.conn.networkLookupByUUIDString(request.uuid) - return _network_to_pb(net) - - def ListNetworks(self, request, context): - return domain_pb2.ListNetworksResponse( - networks=[_network_to_pb(net) for net in (self.conn.listAllNetworks())] - ) - - def CreateNetwork(self, request, context): - network = request.network - - try: - net_json = {} - if network.cidr: - net_json["cidr4"] = network.cidr - if network.cidr6: - net_json["cidr6"] = network.cidr6 - res = requests.post( - "http://localhost:8081/networks", - json={"network": net_json}, - ) - res.raise_for_status() - virtuerl_net = res.json() - net_id = virtuerl_net["id"] - except HTTPError as e: - raise e - - return domain_pb2.Network( - uuid=net_id, - name="name", - cidr=network.cidr, - cidr6=network.cidr6, - ) - - def DeleteNetwork(self, request, context): - try: - net = self.conn.networkLookupByUUIDString(request.uuid) - try: - net.destroy() - except: - pass - net.undefine() - except: - pass - - requests.delete(f"http://localhost:8081/networks/{request.uuid}") - - return empty_pb2.Empty() - - def StartDomain(self, request, context): - domain = self.conn.lookupByUUIDString(request.uuid) - domain.create() - return empty_pb2.Empty() - - def StopDomain(self, request, context): - domain = self.conn.lookupByUUIDString(request.uuid) - if request.force: - domain.destroy() - else: - domain.shutdown() - return empty_pb2.Empty() - - def _get_domain(self, uuid): - domain_lv = self.conn.lookupByUUIDString(uuid) - domain_dict = domain_to_dict(domain_lv) - try: - net = self.conn.networkLookupByName(domain_dict["network"]) - domain_dict["network"] = net.UUIDString() - except: - res = requests.get(f"http://localhost:8081/domains/{uuid}") - resj = res.json() - domain_dict["network"] = resj["network_id"] - state, _ = domain_lv.state() - domain_dict["state"] = libvirt_state_to_string(state) - - with self.session_factory() as session: - domain = ( - session.execute( - select(Domain).filter( - Domain.id == uuid, - ) - ) - .scalars() - .one_or_none() - ) - domain_dict["os_type"] = domain.os_type - domain_dict["private_ip"] = domain.private_ip - domain_dict["ipv6_address"] = domain.ipv6_address - domain_dict["user_data"] = domain.user_data - - return domain_dict - - def GetDomain(self, request, context): - return domain_pb2.Domain(**self._get_domain(request.uuid)) - - def ListDomains(self, request, context): - domains = self.conn.listAllDomains() - ds = [domain_pb2.Domain(**domain_to_dict(d)) for d in domains] - return domain_pb2.ListDomainsResponse(domains=ds) - - def CreateDomain(self, request, context): - domreq = request.domain - - req_net = {"domain": {"network_id": domreq.network}} - private_ip = domreq.private_ip - if private_ip: - req_net["domain"]["ipv4_addr"] = private_ip - ipv6_address = domreq.ipv6_address - if ipv6_address: - req_net["domain"]["ipv6_addr"] = ipv6_address - - mac = None - try: - res = requests.post("http://localhost:8081/domains", json=req_net) - res.raise_for_status() - virtuerl_dom = res.json() - dom_id = virtuerl_dom["id"] - tap_name = virtuerl_dom["tap_name"] - ip_addr = virtuerl_dom["ipv4_addr"] - mac = virtuerl_dom["mac_addr"] - mac = ":".join(re.findall("..", mac.lower())) - if ipv6_address: - ip6_addr = virtuerl_dom["ipv6_addr"] - except HTTPError as e: - raise e - - gateway6 = None - net6 = None - - try: - lvnet = self.conn.networkLookupByUUIDString(domreq.network) - - net_dict = xmltodict.parse(lvnet.XMLDesc(), force_list=("ip",)) - net_def = net_dict["network"]["ip"][0] - gateway = ipaddress.ip_address(net_def["@address"]) - net = ipaddress.ip_network(f"{gateway}/{_network_prefix(net_def)}", strict=False) - - if len(net_dict["network"]["ip"]) > 1: - net6_def = net_dict["network"]["ip"][1] - gateway6 = ipaddress.ip_address(net6_def["@address"]) - net6 = ipaddress.ip_network(f'{gateway6}/{net6_def["@prefix"]}', strict=False) - - is_virtuerl_net = False - except libvirt.libvirtError as e: - if e.get_error_code() != libvirt.VIR_ERR_NO_NETWORK: - raise e - private_ip = ip_addr - - vres = requests.get(f"http://localhost:8081/networks/{domreq.network}") - vres.raise_for_status() - vresj = vres.json() - cidrs = [ipaddress.ip_network(cidr, strict=False) for cidr in vresj["cidrs"]] - cidr4 = [cidr for cidr in cidrs if isinstance(cidr, ipaddress.IPv4Network)] - cidr6 = [cidr for cidr in cidrs if isinstance(cidr, ipaddress.IPv6Network)] - net = cidr4[0] - gateway = net[1] - if ipv6_address: - net6 = cidr6[0] - gateway6 = net6[1] - - is_virtuerl_net = True - - dom_uuid = dom_id - os_type = domreq.os_type - if os_type is None: - os_type = "linux" - user_data = domreq.user_data - if user_data is None: - user_data = "" - with self.lock: - with self.session_factory() as session: - domains = session.execute(select(Domain)).scalars().all() - - ips = set([dom.private_ip for dom in domains]) - if not private_ip: - available = {str(h) for h in net.hosts()} - available -= {str(net.network_address), str(net.broadcast_address)} - available -= ips - private_ip = available.pop() - else: - assert private_ip not in ips - - domain = Domain( - id=str(dom_uuid), - os_type=os_type, - private_ip=private_ip, - ipv6_address=ipv6_address, - user_data=user_data, - ) - session.add(domain) - session.commit() - - ip = ipaddress.ip_address(private_ip) - ip6 = ipaddress.ip_address(ipv6_address) if ipv6_address else None - if mac is None: - mac = "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format( - 0x52, 0x54, 0x00, ip.packed[-3], ip.packed[-2], ip.packed[-1] - ) - - if is_virtuerl_net: - netxml = f""" - - - - -""" - else: - netxml = f""" - - - - -""" - - img_pool = self.conn.storagePoolLookupByName("restvirtimages") - if not domreq.base_image: - base_img_name = "debian-12-generic-amd64-20240102-1614.qcow2" - try: - base_img = img_pool.storageVolLookupByName(base_img_name) - except: - from urllib.request import urlopen - - res = urlopen( - f"https://cloud.debian.org/images/cloud/bookworm/20240102-1614/debian-12-generic-amd64-20240102-1614.qcow2" - ) - size = int(res.getheader("Content-length")) - base_img = img_pool.createXML( - f""" - {base_img_name} - {size} - - - -""" - ) - stream = self.conn.newStream() - base_img.upload(stream, 0, size) - while True: - chunk = res.read(64 * 1024) - if not chunk: - break - stream.send(chunk) - stream.finish() - else: - base_img = img_pool.storageVolLookupByName(domreq.base_image) - - vol_pool = self.conn.storagePoolLookupByName("volumes") - vol = vol_pool.createXML( - f""" - {domreq.name}-root.qcow2 - {20} - - {base_img.path()} - - - - - -""" - ) - root_image_path = vol.path() - - ccfg_raw = create_cloud_config_image( - domain_id=dom_uuid, - user_data=user_data, - mac=mac, - network=net, - network6=net6, - address=ip, - address6=ip6, - gateway=net[1], - gateway6=gateway6, - name=domreq.name, - ) - stream = self.conn.newStream() - ccfg_vol = img_pool.createXML( - f""" - {domreq.name}-cloud-init.img - {len(ccfg_raw)} - - - -""" - ) - ccfg_vol.upload(stream, 0, len(ccfg_raw)) - stream.send(ccfg_raw) - stream.finish() - - creation_timestamp = datetime.now(timezone.utc) - dom = self.conn.defineXML( - f""" - {dom_uuid} - - - {creation_timestamp.isoformat()} - - - - - - {"" if domreq.nested_virtualization else ""} - {domreq.name} - {domreq.vcpu} - {domreq.memory} - - hvm - - - - - - - - - - - - - {netxml} - - -""" - ) - - dom.setAutostart(True) - dom.create() - - return domain_pb2.Domain(**self._get_domain(dom.UUIDString())) - - def DeleteDomain(self, request, context): - with self.session_factory() as session: - session.execute(delete(Domain).where(Domain.id == request.uuid)) - session.commit() - - dom = self.conn.lookupByUUIDString(str(request.uuid)) - name = dom.name() - try: - dom.destroy() - except libvirt.libvirtError as e: - if "Requested operation is not valid: domain is not running" in str(e): - pass - else: - raise e - dom.undefine() - - pool = self.conn.storagePoolLookupByName("restvirtimages") - vol = get_root_volume(self.conn, name) - vol.delete() - vol = pool.storageVolLookupByName(f"{name}-cloud-init.img") - vol.delete() - - requests.delete(f"http://localhost:8081/domains/{str(request.uuid)}") - - return empty_pb2.Empty() - - def DownloadImage(self, request, context): - dom = self.conn.lookupByUUIDString(request.domain_id) - name = dom.name() - vol = get_root_volume(self.conn, name) - stream = self.conn.newStream() - vol.download(stream, 0, 0) - while True: - bytes = stream.recv(64 * 1024) - if not bytes: - break - yield domain_pb2.ImageChunk(bytes=bytes) - stream.finish() - - def GetVolume(self, request, context): - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(request.uuid) - return volume_pb2.Volume(**_volume_to_dict(vol)) - - def ListVolumes(self, request, context): - pool = self.conn.storagePoolLookupByName("volumes") - vols = pool.listAllVolumes() - vol_dicts = [_volume_to_dict(vol) for vol in vols] - return volume_pb2.ListVolumesResponse(volumes=[volume_pb2.Volume(**d) for d in vol_dicts]) - - def CreateVolume(self, request, context): - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.createXML( - f""" - {request.volume.name} - {request.volume.size} - - - -""" - ) - return volume_pb2.Volume( - id=vol.name(), - name=request.volume.name, - size=request.volume.size, - ) - - def UpdateVolume(self, request, context): - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(request.volume.id) - _, current_capacity, _ = vol.info() - desired_capacity = request.volume.size - if desired_capacity < current_capacity: - raise Exception("shrinking volumes is not supported") - vol.resize(desired_capacity) - return volume_pb2.Volume(**_volume_to_dict(vol)) - - def DeleteVolume(self, request, context): - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(request.uuid) - if _get_all_attachments(self.conn.listAllDomains(), vol): - raise Exception("volume is attached z") - vol.delete() - return empty_pb2.Empty() - - def ListVolumeAttachments(self, request, context): - domain = self.conn.lookupByUUIDString(request.domain_id) - return volume_pb2.ListVolumeAttachmentsResponse( - attachments=[ - volume_pb2.VolumeAttachment(domain_id=request.domain_id, **a) - for a in _get_attachments(domain) - ] - ) - - def GetVolumeAttachment(self, request, context): - domain = self.conn.lookupByUUIDString(request.domain_id) - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(request.volume_id) - - return volume_pb2.VolumeAttachment( - domain_id=domain.UUIDString(), - volume_id=vol.name(), - disk_address=disk_address(domain, request.volume_id), - ) - - def AttachVolume(self, request, context): - domain = self.conn.lookupByUUIDString(request.domain_id) - pool = self.conn.storagePoolLookupByName("volumes") - vol = pool.storageVolLookupByName(request.volume_id) - - domain_dict = xmltodict.parse(domain.XMLDesc()) - disks = domain_dict["domain"]["devices"]["disk"] - - volumes_ids = [ - d["alias"]["@name"][3:] - for d in disks - if d["@device"] == "disk" and d["alias"]["@name"].startswith("ua-") - ] - - if request.volume_id in volumes_ids: - return volume_pb2.VolumeAttachment( - domain_id=request.domain_id, - volume_id=request.volume_id, - disk_address=disk_address(domain, request.volume_id), - ) - - disk_shortnames = [d["target"]["@dev"][-1:] for d in disks] - disk_letter = sorted(set(string.ascii_lowercase).difference(disk_shortnames))[0] - domain.attachDeviceFlags( - f""" - - - - - - """, - libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_AFFECT_CONFIG, - ) - - return volume_pb2.VolumeAttachment( - domain_id=request.domain_id, - volume_id=request.volume_id, - disk_address=disk_address(domain, request.volume_id), - ) - - def DetachVolume(self, request, context): - domain = self.conn.lookupByUUIDString(request.domain_id) - alias = f"ua-{request.volume_id}" - try: - domain.detachDeviceAlias( - alias, - libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_AFFECT_CONFIG, - ) - except libvirt.libvirtError as e: - if f"no device found with alias {alias}" not in e.get_error_message(): - raise e - return empty_pb2.Empty() - - def GetPortForwarding(self, request, context): - with self.session_factory() as session: - forwarding = ( - session.execute( - select(PortForwarding).filter( - PortForwarding.protocol == request.protocol, - PortForwarding.source_port == request.source_port, - ) - ) - .scalars() - .one_or_none() - ) - if forwarding is None: - context.set_code(StatusCode.NOT_FOUND) - return empty_pb2.Empty() - return port_forwarding_pb2.PortForwarding( - protocol=forwarding.protocol, - source_port=forwarding.source_port, - target_ip=forwarding.target_ip, - target_port=forwarding.target_port, - ) - - def ListPortForwardings(self, request, context): - with self.session_factory() as session: - fwds = session.execute(select(PortForwarding)).scalars().all() - return port_forwarding_pb2.ListPortForwardingsResponse( - port_forwardings=[ - port_forwarding_pb2.PortForwarding( - protocol=fwd.protocol, - source_port=fwd.source_port, - target_ip=fwd.target_ip, - target_port=fwd.target_port, - ) - for fwd in fwds - ] - ) - - def PutPortForwarding(self, request, context): - f = request.port_forwarding - route = PortForwarding( - protocol=f.protocol, - source_port=f.source_port, - target_ip=f.target_ip, - target_port=f.target_port, - ) - - with self.session_factory() as session: - session.merge(route) - session.commit() - self.port_fwd_sync_handler.handle_sync(session, self.conn) - - return f - - def DeletePortForwarding(self, request, context): - with self.session_factory() as session: - session.execute( - delete(PortForwarding).where( - PortForwarding.protocol == request.protocol, - PortForwarding.source_port == request.source_port, - ) - ) - session.commit() - self.port_fwd_sync_handler.handle_sync(session, self.conn) - - return empty_pb2.Empty() - - def sync(self): - with self.session_factory() as session: - self.port_fwd_sync_handler.handle_sync(session, self.conn) - - def SyncRoutes(self, request, context): - self.tables_synchronizer.handle_sync(self.controller) - self.routes_synchronizer.handle_sync(self.controller) - return empty_pb2.Empty() diff --git a/minivirt/daemon_pb2.py b/minivirt/daemon_pb2.py deleted file mode 100644 index 0ce5595..0000000 --- a/minivirt/daemon_pb2.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/daemon.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import domain_pb2 as minivirt_dot_domain__pb2 -from minivirt import volume_pb2 as minivirt_dot_volume__pb2 -from minivirt import port_forwarding_pb2 as minivirt_dot_port__forwarding__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15minivirt/daemon.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15minivirt/domain.proto\x1a\x15minivirt/volume.proto\x1a\x1eminivirt/port_forwarding.proto\"\x13\n\x11SyncRoutesRequest2\x95\x0c\n\rDaemonService\x12,\n\nGetNetwork\x12\x12.GetNetworkRequest\x1a\x08.Network\"\x00\x12=\n\x0cListNetworks\x12\x14.ListNetworksRequest\x1a\x15.ListNetworksResponse\"\x00\x12\x32\n\rCreateNetwork\x12\x15.CreateNetworkRequest\x1a\x08.Network\"\x00\x12@\n\rDeleteNetwork\x12\x15.DeleteNetworkRequest\x1a\x16.google.protobuf.Empty\"\x00\x12<\n\x0bStartDomain\x12\x13.StartDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12:\n\nStopDomain\x12\x12.StopDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12)\n\tGetDomain\x12\x11.GetDomainRequest\x1a\x07.Domain\"\x00\x12:\n\x0bListDomains\x12\x13.ListDomainsRequest\x1a\x14.ListDomainsResponse\"\x00\x12/\n\x0c\x43reateDomain\x12\x14.CreateDomainRequest\x1a\x07.Domain\"\x00\x12>\n\x0c\x44\x65leteDomain\x12\x14.DeleteDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12\x37\n\rDownloadImage\x12\x15.DownloadImageRequest\x1a\x0b.ImageChunk\"\x00\x30\x01\x12)\n\tGetVolume\x12\x11.GetVolumeRequest\x1a\x07.Volume\"\x00\x12:\n\x0bListVolumes\x12\x13.ListVolumesRequest\x1a\x14.ListVolumesResponse\"\x00\x12/\n\x0c\x43reateVolume\x12\x14.CreateVolumeRequest\x1a\x07.Volume\"\x00\x12/\n\x0cUpdateVolume\x12\x14.UpdateVolumeRequest\x1a\x07.Volume\"\x00\x12>\n\x0c\x44\x65leteVolume\x12\x14.DeleteVolumeRequest\x1a\x16.google.protobuf.Empty\"\x00\x12X\n\x15ListVolumeAttachments\x12\x1d.ListVolumeAttachmentsRequest\x1a\x1e.ListVolumeAttachmentsResponse\"\x00\x12G\n\x13GetVolumeAttachment\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12@\n\x0c\x41ttachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12\x45\n\x0c\x44\x65tachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12\x41\n\x11GetPortForwarding\x12\x19.PortForwardingIdentifier\x1a\x0f.PortForwarding\"\x00\x12R\n\x13ListPortForwardings\x12\x1b.ListPortForwardingsRequest\x1a\x1c.ListPortForwardingsResponse\"\x00\x12\x41\n\x11PutPortForwarding\x12\x19.PutPortForwardingRequest\x1a\x0f.PortForwarding\"\x00\x12K\n\x14\x44\x65letePortForwarding\x12\x19.PortForwardingIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12:\n\nSyncRoutes\x12\x12.SyncRoutesRequest\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.daemon_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _SYNCROUTESREQUEST._serialized_start=132 - _SYNCROUTESREQUEST._serialized_end=151 - _DAEMONSERVICE._serialized_start=154 - _DAEMONSERVICE._serialized_end=1711 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/daemon_pb2_grpc.py b/minivirt/daemon_pb2_grpc.py deleted file mode 100644 index d202fd5..0000000 --- a/minivirt/daemon_pb2_grpc.py +++ /dev/null @@ -1,862 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import daemon_pb2 as minivirt_dot_daemon__pb2 -from minivirt import domain_pb2 as minivirt_dot_domain__pb2 -from minivirt import port_forwarding_pb2 as minivirt_dot_port__forwarding__pb2 -from minivirt import volume_pb2 as minivirt_dot_volume__pb2 - - -class DaemonServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetNetwork = channel.unary_unary( - '/DaemonService/GetNetwork', - request_serializer=minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.ListNetworks = channel.unary_unary( - '/DaemonService/ListNetworks', - request_serializer=minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - ) - self.CreateNetwork = channel.unary_unary( - '/DaemonService/CreateNetwork', - request_serializer=minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.DeleteNetwork = channel.unary_unary( - '/DaemonService/DeleteNetwork', - request_serializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.StartDomain = channel.unary_unary( - '/DaemonService/StartDomain', - request_serializer=minivirt_dot_domain__pb2.StartDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.StopDomain = channel.unary_unary( - '/DaemonService/StopDomain', - request_serializer=minivirt_dot_domain__pb2.StopDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetDomain = channel.unary_unary( - '/DaemonService/GetDomain', - request_serializer=minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.ListDomains = channel.unary_unary( - '/DaemonService/ListDomains', - request_serializer=minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - ) - self.CreateDomain = channel.unary_unary( - '/DaemonService/CreateDomain', - request_serializer=minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.DeleteDomain = channel.unary_unary( - '/DaemonService/DeleteDomain', - request_serializer=minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.DownloadImage = channel.unary_stream( - '/DaemonService/DownloadImage', - request_serializer=minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ImageChunk.FromString, - ) - self.GetVolume = channel.unary_unary( - '/DaemonService/GetVolume', - request_serializer=minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.ListVolumes = channel.unary_unary( - '/DaemonService/ListVolumes', - request_serializer=minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - ) - self.CreateVolume = channel.unary_unary( - '/DaemonService/CreateVolume', - request_serializer=minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.UpdateVolume = channel.unary_unary( - '/DaemonService/UpdateVolume', - request_serializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.DeleteVolume = channel.unary_unary( - '/DaemonService/DeleteVolume', - request_serializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.ListVolumeAttachments = channel.unary_unary( - '/DaemonService/ListVolumeAttachments', - request_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - ) - self.GetVolumeAttachment = channel.unary_unary( - '/DaemonService/GetVolumeAttachment', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.AttachVolume = channel.unary_unary( - '/DaemonService/AttachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.DetachVolume = channel.unary_unary( - '/DaemonService/DetachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetPortForwarding = channel.unary_unary( - '/DaemonService/GetPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.ListPortForwardings = channel.unary_unary( - '/DaemonService/ListPortForwardings', - request_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - ) - self.PutPortForwarding = channel.unary_unary( - '/DaemonService/PutPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.DeletePortForwarding = channel.unary_unary( - '/DaemonService/DeletePortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.SyncRoutes = channel.unary_unary( - '/DaemonService/SyncRoutes', - request_serializer=minivirt_dot_daemon__pb2.SyncRoutesRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class DaemonServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListNetworks(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StartDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StopDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListDomains(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DownloadImage(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UpdateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumeAttachments(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetVolumeAttachment(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def AttachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DetachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListPortForwardings(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeletePortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def SyncRoutes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_DaemonServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetNetwork': grpc.unary_unary_rpc_method_handler( - servicer.GetNetwork, - request_deserializer=minivirt_dot_domain__pb2.GetNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'ListNetworks': grpc.unary_unary_rpc_method_handler( - servicer.ListNetworks, - request_deserializer=minivirt_dot_domain__pb2.ListNetworksRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListNetworksResponse.SerializeToString, - ), - 'CreateNetwork': grpc.unary_unary_rpc_method_handler( - servicer.CreateNetwork, - request_deserializer=minivirt_dot_domain__pb2.CreateNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'DeleteNetwork': grpc.unary_unary_rpc_method_handler( - servicer.DeleteNetwork, - request_deserializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'StartDomain': grpc.unary_unary_rpc_method_handler( - servicer.StartDomain, - request_deserializer=minivirt_dot_domain__pb2.StartDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'StopDomain': grpc.unary_unary_rpc_method_handler( - servicer.StopDomain, - request_deserializer=minivirt_dot_domain__pb2.StopDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetDomain': grpc.unary_unary_rpc_method_handler( - servicer.GetDomain, - request_deserializer=minivirt_dot_domain__pb2.GetDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'ListDomains': grpc.unary_unary_rpc_method_handler( - servicer.ListDomains, - request_deserializer=minivirt_dot_domain__pb2.ListDomainsRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListDomainsResponse.SerializeToString, - ), - 'CreateDomain': grpc.unary_unary_rpc_method_handler( - servicer.CreateDomain, - request_deserializer=minivirt_dot_domain__pb2.CreateDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'DeleteDomain': grpc.unary_unary_rpc_method_handler( - servicer.DeleteDomain, - request_deserializer=minivirt_dot_domain__pb2.DeleteDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'DownloadImage': grpc.unary_stream_rpc_method_handler( - servicer.DownloadImage, - request_deserializer=minivirt_dot_domain__pb2.DownloadImageRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ImageChunk.SerializeToString, - ), - 'GetVolume': grpc.unary_unary_rpc_method_handler( - servicer.GetVolume, - request_deserializer=minivirt_dot_volume__pb2.GetVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'ListVolumes': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumes, - request_deserializer=minivirt_dot_volume__pb2.ListVolumesRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumesResponse.SerializeToString, - ), - 'CreateVolume': grpc.unary_unary_rpc_method_handler( - servicer.CreateVolume, - request_deserializer=minivirt_dot_volume__pb2.CreateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'UpdateVolume': grpc.unary_unary_rpc_method_handler( - servicer.UpdateVolume, - request_deserializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'DeleteVolume': grpc.unary_unary_rpc_method_handler( - servicer.DeleteVolume, - request_deserializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'ListVolumeAttachments': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumeAttachments, - request_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.SerializeToString, - ), - 'GetVolumeAttachment': grpc.unary_unary_rpc_method_handler( - servicer.GetVolumeAttachment, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'AttachVolume': grpc.unary_unary_rpc_method_handler( - servicer.AttachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'DetachVolume': grpc.unary_unary_rpc_method_handler( - servicer.DetachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.GetPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'ListPortForwardings': grpc.unary_unary_rpc_method_handler( - servicer.ListPortForwardings, - request_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.SerializeToString, - ), - 'PutPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.PutPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'DeletePortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.DeletePortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'SyncRoutes': grpc.unary_unary_rpc_method_handler( - servicer.SyncRoutes, - request_deserializer=minivirt_dot_daemon__pb2.SyncRoutesRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'DaemonService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class DaemonService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/GetNetwork', - minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListNetworks(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/ListNetworks', - minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/CreateNetwork', - minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/DeleteNetwork', - minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def StartDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/StartDomain', - minivirt_dot_domain__pb2.StartDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def StopDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/StopDomain', - minivirt_dot_domain__pb2.StopDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/GetDomain', - minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListDomains(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/ListDomains', - minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/CreateDomain', - minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/DeleteDomain', - minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DownloadImage(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream(request, target, '/DaemonService/DownloadImage', - minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - minivirt_dot_domain__pb2.ImageChunk.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/GetVolume', - minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/ListVolumes', - minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/CreateVolume', - minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def UpdateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/UpdateVolume', - minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/DeleteVolume', - minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumeAttachments(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/ListVolumeAttachments', - minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetVolumeAttachment(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/GetVolumeAttachment', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def AttachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/AttachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DetachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/DetachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/GetPortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListPortForwardings(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/ListPortForwardings', - minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/PutPortForwarding', - minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeletePortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/DeletePortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def SyncRoutes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DaemonService/SyncRoutes', - minivirt_dot_daemon__pb2.SyncRoutesRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/dns_controller.py b/minivirt/dns_controller.py deleted file mode 100644 index 119ef39..0000000 --- a/minivirt/dns_controller.py +++ /dev/null @@ -1,104 +0,0 @@ -from dns import resolver -from dnslib import QTYPE, RCODE, RR, copy -from dnslib.server import DNSServer -from sqlalchemy import delete, select - -from minivirt.models import DNSRecord - - -class DNSController: - def __init__(self, session_factory): - self.session_factory = session_factory - self.server = None - - r = resolver.Resolver() - self.upstream = r.nameservers[0] - - def records(self): - with self.session_factory() as session: - return session.execute(select(DNSRecord)).scalars().all() - - def record(self, name, type): - with self.session_factory() as session: - return ( - session.execute( - select(DNSRecord).filter( - DNSRecord.name == name, - DNSRecord.type == type, - ) - ) - .scalars() - .one_or_none() - ) - - def load_zone_list(self): - zone_file = "\n".join( - [f"{f.name} {f.ttl} {f.type} {' '.join(f.records)}" for f in self.records()] - ) - return [(rr.rname, QTYPE[rr.rtype], rr) for rr in RR.fromZone(zone_file)] - - def set(self, record: DNSRecord): - with self.session_factory() as session: - session.merge(record) - session.commit() - - def remove(self, name, type): - with self.session_factory() as session: - session.execute( - delete(DNSRecord).where( - DNSRecord.name == name, - DNSRecord.type == type, - ) - ) - session.commit() - - def resolve(self, request, handler): - zone = self.load_zone_list() - - reply = None - qname = request.q.qname - qtype = QTYPE[request.q.qtype] - for name, rtype, rr in zone: - # Check if label & type match - if qname.matchGlob(name): - reply = request.reply() - if qtype == rtype or qtype == "ANY" or rtype == "CNAME": - # Since we have a glob match fix reply label - a = copy.copy(rr) - a.rname = qname - reply.add_answer(a) - # Check for A/AAAA records associated with reply and - # add in additional section - if rtype in ["CNAME", "NS", "MX", "PTR"]: - for a_name, a_rtype, a_rr in zone: - if a_name == rr.rdata.label and a_rtype in ["A", "AAAA"]: - reply.add_answer(a_rr) - - if reply is None: - # check for zone delegation - for name, rtype, rr in zone: - if rtype == "NS" and qname.matchSuffix(name): - if reply is None: - reply = request.reply() - reply.add_auth(copy.copy(rr)) - - if reply is None: - # try: - # reply = dnslib.DNSRecord.parse(request.send(self.upstream, 53, timeout=3)) - # except socket.timeout: - # reply.header.rcode = RCODE.SERVFAIL - reply = request.reply() - reply.header.rcode = RCODE.NXDOMAIN - reply.header.ra = False # we don't support recursion - return reply - - def start(self, port=53): - self.server = DNSServer(self, port=port) - self.server.start_thread() - return self.server.server.server_address[1] - - def stop(self): - if self.server is not None: - self.server.stop() - self.server.server.server_close() - self.server = None diff --git a/minivirt/dns_pb2.py b/minivirt/dns_pb2.py deleted file mode 100644 index ed12e7f..0000000 --- a/minivirt/dns_pb2.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/dns.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12minivirt/dns.proto\x1a\x1bgoogle/protobuf/empty.proto\"1\n\x13\x44NSRecordIdentifier\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\"E\n\tDNSRecord\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\x12\x0b\n\x03ttl\x18\x03 \x01(\x04\x12\x0f\n\x07records\x18\x04 \x03(\t\"\x17\n\x15ListDNSRecordsRequest\"9\n\x16ListDNSRecordsResponse\x12\x1f\n\x0b\x64ns_records\x18\x01 \x03(\x0b\x32\n.DNSRecord\"5\n\x13PutDNSRecordRequest\x12\x1e\n\ndns_record\x18\x01 \x01(\x0b\x32\n.DNSRecord2\xf5\x01\n\x03\x44NS\x12\x32\n\x0cGetDNSRecord\x12\x14.DNSRecordIdentifier\x1a\n.DNSRecord\"\x00\x12\x43\n\x0eListDNSRecords\x12\x16.ListDNSRecordsRequest\x1a\x17.ListDNSRecordsResponse\"\x00\x12\x32\n\x0cPutDNSRecord\x12\x14.PutDNSRecordRequest\x1a\n.DNSRecord\"\x00\x12\x41\n\x0f\x44\x65leteDNSRecord\x12\x14.DNSRecordIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.dns_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _DNSRECORDIDENTIFIER._serialized_start=51 - _DNSRECORDIDENTIFIER._serialized_end=100 - _DNSRECORD._serialized_start=102 - _DNSRECORD._serialized_end=171 - _LISTDNSRECORDSREQUEST._serialized_start=173 - _LISTDNSRECORDSREQUEST._serialized_end=196 - _LISTDNSRECORDSRESPONSE._serialized_start=198 - _LISTDNSRECORDSRESPONSE._serialized_end=255 - _PUTDNSRECORDREQUEST._serialized_start=257 - _PUTDNSRECORDREQUEST._serialized_end=310 - _DNS._serialized_start=313 - _DNS._serialized_end=558 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/dns_pb2_grpc.py b/minivirt/dns_pb2_grpc.py deleted file mode 100644 index 727efe5..0000000 --- a/minivirt/dns_pb2_grpc.py +++ /dev/null @@ -1,166 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import dns_pb2 as minivirt_dot_dns__pb2 - - -class DNSStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetDNSRecord = channel.unary_unary( - '/DNS/GetDNSRecord', - request_serializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.DNSRecord.FromString, - ) - self.ListDNSRecords = channel.unary_unary( - '/DNS/ListDNSRecords', - request_serializer=minivirt_dot_dns__pb2.ListDNSRecordsRequest.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.ListDNSRecordsResponse.FromString, - ) - self.PutDNSRecord = channel.unary_unary( - '/DNS/PutDNSRecord', - request_serializer=minivirt_dot_dns__pb2.PutDNSRecordRequest.SerializeToString, - response_deserializer=minivirt_dot_dns__pb2.DNSRecord.FromString, - ) - self.DeleteDNSRecord = channel.unary_unary( - '/DNS/DeleteDNSRecord', - request_serializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class DNSServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListDNSRecords(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteDNSRecord(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_DNSServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.GetDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.FromString, - response_serializer=minivirt_dot_dns__pb2.DNSRecord.SerializeToString, - ), - 'ListDNSRecords': grpc.unary_unary_rpc_method_handler( - servicer.ListDNSRecords, - request_deserializer=minivirt_dot_dns__pb2.ListDNSRecordsRequest.FromString, - response_serializer=minivirt_dot_dns__pb2.ListDNSRecordsResponse.SerializeToString, - ), - 'PutDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.PutDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.PutDNSRecordRequest.FromString, - response_serializer=minivirt_dot_dns__pb2.DNSRecord.SerializeToString, - ), - 'DeleteDNSRecord': grpc.unary_unary_rpc_method_handler( - servicer.DeleteDNSRecord, - request_deserializer=minivirt_dot_dns__pb2.DNSRecordIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'DNS', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class DNS(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DNS/GetDNSRecord', - minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - minivirt_dot_dns__pb2.DNSRecord.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListDNSRecords(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DNS/ListDNSRecords', - minivirt_dot_dns__pb2.ListDNSRecordsRequest.SerializeToString, - minivirt_dot_dns__pb2.ListDNSRecordsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DNS/PutDNSRecord', - minivirt_dot_dns__pb2.PutDNSRecordRequest.SerializeToString, - minivirt_dot_dns__pb2.DNSRecord.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteDNSRecord(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DNS/DeleteDNSRecord', - minivirt_dot_dns__pb2.DNSRecordIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/domain_pb2.py b/minivirt/domain_pb2.py deleted file mode 100644 index 8f041ec..0000000 --- a/minivirt/domain_pb2.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/domain.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15minivirt/domain.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"0\n\x12StartDomainRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04uuid\x18\x02 \x01(\t\">\n\x11StopDomainRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x12\r\n\x05\x66orce\x18\x03 \x01(\x08\".\n\x10GetDomainRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"\xaf\x02\n\x06\x44omain\x12\n\n\x02id\x18\x01 \x01(\x04\x12\x0c\n\x04uuid\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x0c\n\x04vcpu\x18\x04 \x01(\r\x12\x0e\n\x06memory\x18\x05 \x01(\x04\x12\x0f\n\x07network\x18\x06 \x01(\t\x12\x0e\n\x06\x62ridge\x18\x07 \x01(\t\x12\r\n\x05state\x18\x08 \x01(\t\x12\x12\n\nprivate_ip\x18\t \x01(\t\x12\x14\n\x0cipv6_address\x18\x0f \x01(\t\x12\x11\n\tuser_data\x18\n \x01(\t\x12\x1d\n\x15nested_virtualization\x18\x0b \x01(\x08\x12\x12\n\nbase_image\x18\x0c \x01(\t\x12.\n\ncreated_at\x18\r \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07os_type\x18\x0e \x01(\t\"\"\n\x12ListDomainsRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\"/\n\x13ListDomainsResponse\x12\x18\n\x07\x64omains\x18\x01 \x03(\x0b\x32\x07.Domain\"<\n\x13\x43reateDomainRequest\x12\x17\n\x06\x64omain\x18\x01 \x01(\x0b\x32\x07.Domain\x12\x0c\n\x04host\x18\x02 \x01(\t\"1\n\x13\x44\x65leteDomainRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"7\n\x14\x44ownloadImageRequest\x12\x11\n\tdomain_id\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"\x1b\n\nImageChunk\x12\r\n\x05\x62ytes\x18\x01 \x01(\x0c\"/\n\x11GetNetworkRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"B\n\x07Network\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0c\n\x04\x63idr\x18\x03 \x01(\t\x12\r\n\x05\x63idr6\x18\x04 \x01(\t\"#\n\x13ListNetworksRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\"2\n\x14ListNetworksResponse\x12\x1a\n\x08networks\x18\x01 \x03(\x0b\x32\x08.Network\"?\n\x14\x43reateNetworkRequest\x12\x19\n\x07network\x18\x01 \x01(\x0b\x32\x08.Network\x12\x0c\n\x04host\x18\x02 \x01(\t\"2\n\x14\x44\x65leteNetworkRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t2\x83\x04\n\rDomainService\x12)\n\tGetDomain\x12\x11.GetDomainRequest\x1a\x07.Domain\"\x00\x12:\n\x0bListDomains\x12\x13.ListDomainsRequest\x1a\x14.ListDomainsResponse\"\x00\x12/\n\x0c\x43reateDomain\x12\x14.CreateDomainRequest\x1a\x07.Domain\"\x00\x12>\n\x0c\x44\x65leteDomain\x12\x14.DeleteDomainRequest\x1a\x16.google.protobuf.Empty\"\x00\x12\x37\n\rDownloadImage\x12\x15.DownloadImageRequest\x1a\x0b.ImageChunk\"\x00\x30\x01\x12,\n\nGetNetwork\x12\x12.GetNetworkRequest\x1a\x08.Network\"\x00\x12=\n\x0cListNetworks\x12\x14.ListNetworksRequest\x1a\x15.ListNetworksResponse\"\x00\x12\x32\n\rCreateNetwork\x12\x15.CreateNetworkRequest\x1a\x08.Network\"\x00\x12@\n\rDeleteNetwork\x12\x15.DeleteNetworkRequest\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.domain_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _STARTDOMAINREQUEST._serialized_start=87 - _STARTDOMAINREQUEST._serialized_end=135 - _STOPDOMAINREQUEST._serialized_start=137 - _STOPDOMAINREQUEST._serialized_end=199 - _GETDOMAINREQUEST._serialized_start=201 - _GETDOMAINREQUEST._serialized_end=247 - _DOMAIN._serialized_start=250 - _DOMAIN._serialized_end=553 - _LISTDOMAINSREQUEST._serialized_start=555 - _LISTDOMAINSREQUEST._serialized_end=589 - _LISTDOMAINSRESPONSE._serialized_start=591 - _LISTDOMAINSRESPONSE._serialized_end=638 - _CREATEDOMAINREQUEST._serialized_start=640 - _CREATEDOMAINREQUEST._serialized_end=700 - _DELETEDOMAINREQUEST._serialized_start=702 - _DELETEDOMAINREQUEST._serialized_end=751 - _DOWNLOADIMAGEREQUEST._serialized_start=753 - _DOWNLOADIMAGEREQUEST._serialized_end=808 - _IMAGECHUNK._serialized_start=810 - _IMAGECHUNK._serialized_end=837 - _GETNETWORKREQUEST._serialized_start=839 - _GETNETWORKREQUEST._serialized_end=886 - _NETWORK._serialized_start=888 - _NETWORK._serialized_end=954 - _LISTNETWORKSREQUEST._serialized_start=956 - _LISTNETWORKSREQUEST._serialized_end=991 - _LISTNETWORKSRESPONSE._serialized_start=993 - _LISTNETWORKSRESPONSE._serialized_end=1043 - _CREATENETWORKREQUEST._serialized_start=1045 - _CREATENETWORKREQUEST._serialized_end=1108 - _DELETENETWORKREQUEST._serialized_start=1110 - _DELETENETWORKREQUEST._serialized_end=1160 - _DOMAINSERVICE._serialized_start=1163 - _DOMAINSERVICE._serialized_end=1678 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/domain_pb2_grpc.py b/minivirt/domain_pb2_grpc.py deleted file mode 100644 index 04e622a..0000000 --- a/minivirt/domain_pb2_grpc.py +++ /dev/null @@ -1,331 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import domain_pb2 as minivirt_dot_domain__pb2 - - -class DomainServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetDomain = channel.unary_unary( - '/DomainService/GetDomain', - request_serializer=minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.ListDomains = channel.unary_unary( - '/DomainService/ListDomains', - request_serializer=minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - ) - self.CreateDomain = channel.unary_unary( - '/DomainService/CreateDomain', - request_serializer=minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Domain.FromString, - ) - self.DeleteDomain = channel.unary_unary( - '/DomainService/DeleteDomain', - request_serializer=minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.DownloadImage = channel.unary_stream( - '/DomainService/DownloadImage', - request_serializer=minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ImageChunk.FromString, - ) - self.GetNetwork = channel.unary_unary( - '/DomainService/GetNetwork', - request_serializer=minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.ListNetworks = channel.unary_unary( - '/DomainService/ListNetworks', - request_serializer=minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - ) - self.CreateNetwork = channel.unary_unary( - '/DomainService/CreateNetwork', - request_serializer=minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - response_deserializer=minivirt_dot_domain__pb2.Network.FromString, - ) - self.DeleteNetwork = channel.unary_unary( - '/DomainService/DeleteNetwork', - request_serializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class DomainServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListDomains(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteDomain(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DownloadImage(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListNetworks(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteNetwork(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_DomainServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetDomain': grpc.unary_unary_rpc_method_handler( - servicer.GetDomain, - request_deserializer=minivirt_dot_domain__pb2.GetDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'ListDomains': grpc.unary_unary_rpc_method_handler( - servicer.ListDomains, - request_deserializer=minivirt_dot_domain__pb2.ListDomainsRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListDomainsResponse.SerializeToString, - ), - 'CreateDomain': grpc.unary_unary_rpc_method_handler( - servicer.CreateDomain, - request_deserializer=minivirt_dot_domain__pb2.CreateDomainRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Domain.SerializeToString, - ), - 'DeleteDomain': grpc.unary_unary_rpc_method_handler( - servicer.DeleteDomain, - request_deserializer=minivirt_dot_domain__pb2.DeleteDomainRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'DownloadImage': grpc.unary_stream_rpc_method_handler( - servicer.DownloadImage, - request_deserializer=minivirt_dot_domain__pb2.DownloadImageRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ImageChunk.SerializeToString, - ), - 'GetNetwork': grpc.unary_unary_rpc_method_handler( - servicer.GetNetwork, - request_deserializer=minivirt_dot_domain__pb2.GetNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'ListNetworks': grpc.unary_unary_rpc_method_handler( - servicer.ListNetworks, - request_deserializer=minivirt_dot_domain__pb2.ListNetworksRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.ListNetworksResponse.SerializeToString, - ), - 'CreateNetwork': grpc.unary_unary_rpc_method_handler( - servicer.CreateNetwork, - request_deserializer=minivirt_dot_domain__pb2.CreateNetworkRequest.FromString, - response_serializer=minivirt_dot_domain__pb2.Network.SerializeToString, - ), - 'DeleteNetwork': grpc.unary_unary_rpc_method_handler( - servicer.DeleteNetwork, - request_deserializer=minivirt_dot_domain__pb2.DeleteNetworkRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'DomainService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class DomainService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/GetDomain', - minivirt_dot_domain__pb2.GetDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListDomains(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/ListDomains', - minivirt_dot_domain__pb2.ListDomainsRequest.SerializeToString, - minivirt_dot_domain__pb2.ListDomainsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/CreateDomain', - minivirt_dot_domain__pb2.CreateDomainRequest.SerializeToString, - minivirt_dot_domain__pb2.Domain.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteDomain(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/DeleteDomain', - minivirt_dot_domain__pb2.DeleteDomainRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DownloadImage(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream(request, target, '/DomainService/DownloadImage', - minivirt_dot_domain__pb2.DownloadImageRequest.SerializeToString, - minivirt_dot_domain__pb2.ImageChunk.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/GetNetwork', - minivirt_dot_domain__pb2.GetNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListNetworks(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/ListNetworks', - minivirt_dot_domain__pb2.ListNetworksRequest.SerializeToString, - minivirt_dot_domain__pb2.ListNetworksResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/CreateNetwork', - minivirt_dot_domain__pb2.CreateNetworkRequest.SerializeToString, - minivirt_dot_domain__pb2.Network.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteNetwork(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/DomainService/DeleteNetwork', - minivirt_dot_domain__pb2.DeleteNetworkRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/host.py b/minivirt/host.py deleted file mode 100644 index c5a317c..0000000 --- a/minivirt/host.py +++ /dev/null @@ -1,126 +0,0 @@ -import threading -import uuid -from datetime import datetime, timedelta - -import grpc -from google.protobuf import empty_pb2 -from grpc import StatusCode -from sqlalchemy import select - -from minivirt import host_pb2, host_pb2_grpc -from minivirt.models import BootstrapToken, Host - - -class HostController: - def __init__(self, session_factory, creds=None): - self.session_factory = session_factory - self.creds = creds - self.lock = threading.Lock() - self.cache = {} - - for host in self.hosts(): - self.cache[host.name] = self._create_channel(host.address) - - def _create_channel(self, address): - if self.creds is not None: - return grpc.secure_channel(address, self.creds) - return grpc.insecure_channel(address) - - def hosts(self): - with self.session_factory() as session: - return session.execute(select(Host)).scalars().all() - - def host(self, name): - with self.session_factory.begin() as session: - return session.get(Host, name) - - def channel(self, hostname): - with self.lock: - return self.cache.get(hostname) - - def channels(self): - with self.lock: - return list(self.cache.values()) - - def register(self, token, hostname, address): - with self.session_factory.begin() as session: - token = session.get(BootstrapToken, token) - if token is None or token.expires_at <= datetime.utcnow(): - raise Exception("BootstrapToken invalid") - session.add(Host(name=hostname, address=address)) - with self.lock: - self.cache[hostname] = self._create_channel(address) - return empty_pb2.Empty() - - def deregister(self, hostname): - with self.session_factory.begin() as session: - host = session.get(Host, hostname) - if host is None: - raise Exception("Host not found") - session.delete(host) - with self.lock: - del self.cache[hostname] - - -class HostService(host_pb2_grpc.HostServiceServicer): - def __init__(self, host_controller: HostController, session_factory): - self.session_factory = session_factory - self.host_controller = host_controller - - def CreateBootstrapToken(self, request, context): - with self.session_factory.begin() as session: - if not request.expires_at: - expires_at = datetime.utcnow() + timedelta(minutes=10) - else: - expires_at = datetime.fromisoformat(request.expires_at) - token = BootstrapToken( - token=str(uuid.uuid4()), - expires_at=expires_at, - ) - session.add(token) - return host_pb2.CreateBootstrapTokenResponse(token=token.token) - - def GetHost(self, request, context): - host = self.host_controller.host(request.name) - if host is None: - context.set_code(StatusCode.NOT_FOUND) - context.set_details("Host not found") - return - return host_pb2.Host(name=host.name, address=host.address) - - def ListHosts(self, request, context): - hosts = self.host_controller.hosts() - hosts = [host_pb2.Host(name=h.name, address=h.address) for h in hosts] - return host_pb2.ListHostsResponse(hosts=hosts) - - def Register(self, request, context): - try: - self.host_controller.register(request.token, request.host.name, request.host.address) - return empty_pb2.Empty() - except Exception as e: - if "BootstrapToken invalid" in str(e): - context.set_code(StatusCode.INVALID_ARGUMENT) - context.set_details("BootstrapToken invalid") - return - raise e - - def Deregister(self, request, context): - try: - self.host_controller.deregister(request.name) - return empty_pb2.Empty() - except Exception as e: - if "Host not found" in str(e): - context.set_code(StatusCode.NOT_FOUND) - context.set_details("Host not found") - return - raise e - - def Heartbeat(self, request, context): - with self.session_factory.begin() as session: - host = session.get(Host, request.host.name) - if host is None: - context.set_code(StatusCode.NOT_FOUND) - context.set_details("Host not found") - return - host.last_heartbeat = datetime.utcnow() - return host_pb2.HeartbeatResponse() diff --git a/minivirt/host_pb2.py b/minivirt/host_pb2.py deleted file mode 100644 index 22c7fd5..0000000 --- a/minivirt/host_pb2.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/host.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13minivirt/host.proto\x1a\x1bgoogle/protobuf/empty.proto\"1\n\x1b\x43reateBootstrapTokenRequest\x12\x12\n\nexpires_at\x18\x01 \x01(\t\"-\n\x1c\x43reateBootstrapTokenResponse\x12\r\n\x05token\x18\x01 \x01(\t\"%\n\x04Host\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\t\"\x12\n\x10ListHostsRequest\")\n\x11ListHostsResponse\x12\x14\n\x05hosts\x18\x01 \x03(\x0b\x32\x05.Host\"9\n\x13RegisterHostRequest\x12\x13\n\x04host\x18\x01 \x01(\x0b\x32\x05.Host\x12\r\n\x05token\x18\x02 \x01(\t\"\'\n\x10HeartbeatRequest\x12\x13\n\x04host\x18\x01 \x01(\x0b\x32\x05.Host\"\x13\n\x11HeartbeatResponse2\xc5\x02\n\x0bHostService\x12U\n\x14\x43reateBootstrapToken\x12\x1c.CreateBootstrapTokenRequest\x1a\x1d.CreateBootstrapTokenResponse\"\x00\x12\x19\n\x07GetHost\x12\x05.Host\x1a\x05.Host\"\x00\x12\x34\n\tListHosts\x12\x11.ListHostsRequest\x1a\x12.ListHostsResponse\"\x00\x12)\n\x08Register\x12\x14.RegisterHostRequest\x1a\x05.Host\"\x00\x12-\n\nDeregister\x12\x05.Host\x1a\x16.google.protobuf.Empty\"\x00\x12\x34\n\tHeartbeat\x12\x11.HeartbeatRequest\x1a\x12.HeartbeatResponse\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.host_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _CREATEBOOTSTRAPTOKENREQUEST._serialized_start=52 - _CREATEBOOTSTRAPTOKENREQUEST._serialized_end=101 - _CREATEBOOTSTRAPTOKENRESPONSE._serialized_start=103 - _CREATEBOOTSTRAPTOKENRESPONSE._serialized_end=148 - _HOST._serialized_start=150 - _HOST._serialized_end=187 - _LISTHOSTSREQUEST._serialized_start=189 - _LISTHOSTSREQUEST._serialized_end=207 - _LISTHOSTSRESPONSE._serialized_start=209 - _LISTHOSTSRESPONSE._serialized_end=250 - _REGISTERHOSTREQUEST._serialized_start=252 - _REGISTERHOSTREQUEST._serialized_end=309 - _HEARTBEATREQUEST._serialized_start=311 - _HEARTBEATREQUEST._serialized_end=350 - _HEARTBEATRESPONSE._serialized_start=352 - _HEARTBEATRESPONSE._serialized_end=371 - _HOSTSERVICE._serialized_start=374 - _HOSTSERVICE._serialized_end=699 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/host_pb2_grpc.py b/minivirt/host_pb2_grpc.py deleted file mode 100644 index ec74a36..0000000 --- a/minivirt/host_pb2_grpc.py +++ /dev/null @@ -1,232 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import host_pb2 as minivirt_dot_host__pb2 - - -class HostServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.CreateBootstrapToken = channel.unary_unary( - '/HostService/CreateBootstrapToken', - request_serializer=minivirt_dot_host__pb2.CreateBootstrapTokenRequest.SerializeToString, - response_deserializer=minivirt_dot_host__pb2.CreateBootstrapTokenResponse.FromString, - ) - self.GetHost = channel.unary_unary( - '/HostService/GetHost', - request_serializer=minivirt_dot_host__pb2.Host.SerializeToString, - response_deserializer=minivirt_dot_host__pb2.Host.FromString, - ) - self.ListHosts = channel.unary_unary( - '/HostService/ListHosts', - request_serializer=minivirt_dot_host__pb2.ListHostsRequest.SerializeToString, - response_deserializer=minivirt_dot_host__pb2.ListHostsResponse.FromString, - ) - self.Register = channel.unary_unary( - '/HostService/Register', - request_serializer=minivirt_dot_host__pb2.RegisterHostRequest.SerializeToString, - response_deserializer=minivirt_dot_host__pb2.Host.FromString, - ) - self.Deregister = channel.unary_unary( - '/HostService/Deregister', - request_serializer=minivirt_dot_host__pb2.Host.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.Heartbeat = channel.unary_unary( - '/HostService/Heartbeat', - request_serializer=minivirt_dot_host__pb2.HeartbeatRequest.SerializeToString, - response_deserializer=minivirt_dot_host__pb2.HeartbeatResponse.FromString, - ) - - -class HostServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def CreateBootstrapToken(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetHost(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListHosts(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Register(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Deregister(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Heartbeat(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_HostServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'CreateBootstrapToken': grpc.unary_unary_rpc_method_handler( - servicer.CreateBootstrapToken, - request_deserializer=minivirt_dot_host__pb2.CreateBootstrapTokenRequest.FromString, - response_serializer=minivirt_dot_host__pb2.CreateBootstrapTokenResponse.SerializeToString, - ), - 'GetHost': grpc.unary_unary_rpc_method_handler( - servicer.GetHost, - request_deserializer=minivirt_dot_host__pb2.Host.FromString, - response_serializer=minivirt_dot_host__pb2.Host.SerializeToString, - ), - 'ListHosts': grpc.unary_unary_rpc_method_handler( - servicer.ListHosts, - request_deserializer=minivirt_dot_host__pb2.ListHostsRequest.FromString, - response_serializer=minivirt_dot_host__pb2.ListHostsResponse.SerializeToString, - ), - 'Register': grpc.unary_unary_rpc_method_handler( - servicer.Register, - request_deserializer=minivirt_dot_host__pb2.RegisterHostRequest.FromString, - response_serializer=minivirt_dot_host__pb2.Host.SerializeToString, - ), - 'Deregister': grpc.unary_unary_rpc_method_handler( - servicer.Deregister, - request_deserializer=minivirt_dot_host__pb2.Host.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'Heartbeat': grpc.unary_unary_rpc_method_handler( - servicer.Heartbeat, - request_deserializer=minivirt_dot_host__pb2.HeartbeatRequest.FromString, - response_serializer=minivirt_dot_host__pb2.HeartbeatResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'HostService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class HostService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def CreateBootstrapToken(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/CreateBootstrapToken', - minivirt_dot_host__pb2.CreateBootstrapTokenRequest.SerializeToString, - minivirt_dot_host__pb2.CreateBootstrapTokenResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetHost(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/GetHost', - minivirt_dot_host__pb2.Host.SerializeToString, - minivirt_dot_host__pb2.Host.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListHosts(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/ListHosts', - minivirt_dot_host__pb2.ListHostsRequest.SerializeToString, - minivirt_dot_host__pb2.ListHostsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Register(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/Register', - minivirt_dot_host__pb2.RegisterHostRequest.SerializeToString, - minivirt_dot_host__pb2.Host.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Deregister(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/Deregister', - minivirt_dot_host__pb2.Host.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Heartbeat(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/HostService/Heartbeat', - minivirt_dot_host__pb2.HeartbeatRequest.SerializeToString, - minivirt_dot_host__pb2.HeartbeatResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/image.py b/minivirt/image.py deleted file mode 100644 index 436512a..0000000 --- a/minivirt/image.py +++ /dev/null @@ -1,91 +0,0 @@ -from io import BytesIO - -import pycdlib -import yaml - - -def _read_from_cloud_config_file(data, section): - section_data = BytesIO() - iso = pycdlib.PyCdlib() - iso.open_fp(BytesIO(data)) - iso.get_file_from_iso_fp(section_data, joliet_path=section) - iso.close() - return section_data.getvalue().decode() - - -def read_user_data_from_cloud_config_image(data): - return _read_from_cloud_config_file(data, "/user-data") - - -def read_ip_from_cloud_config_image(data): - network_config = _read_from_cloud_config_file(data, "/network-config") - network_config_dict = yaml.safe_load(network_config) - cidr = network_config_dict["ethernets"]["primary"]["addresses"][0] - ip, prefix = cidr.split("/") - return ip - - -def create_cloud_config_image( - domain_id, user_data, mac, network, network6, address, address6, gateway, gateway6, name -): - assert gateway in network - assert address in network - - if network6 is not None: - assert gateway6 in network6 - assert address6 in network6 - - network_config = f"""version: 2 -ethernets: - primary: - match: - macaddress: "{mac}" - set-name: "ens2" - dhcp4: false - dhcp6: false - # default libvirt network - addresses: - - {address}/{network.prefixlen} - {f"- {address6}/{network6.prefixlen}" if address6 is not None else ""} - gateway4: {gateway} - {f"gateway6: {gateway6}" if gateway6 is not None else ""} - nameservers: - addresses: - - {gateway} - {f"- {gateway6}" if gateway6 is not None else ""} -""" - - meta_config = f"""instance-id: {domain_id} -local-hostname: {name} -""" - - iso = pycdlib.PyCdlib() - iso.new( - interchange_level=3, - joliet=3, - rock_ridge="1.09", - vol_ident="cidata", - sys_ident="LINUX", - ) - - iso_config = { - "network-config": network_config, - "meta-data": meta_config, - "user-data": user_data, - } - - for section_name, data_string in iso_config.items(): - data = data_string.encode() - iso.add_fp( - BytesIO(data), - len(data), - iso_path=f'/{section_name.replace("-", "").upper()}.;1', - rr_name=section_name, - joliet_path=f"/{section_name}", - ) - - result = BytesIO() - iso.write_fp(result) - iso.close() - - return result.getvalue() diff --git a/minivirt/main.py b/minivirt/main.py deleted file mode 100644 index f4e69a8..0000000 --- a/minivirt/main.py +++ /dev/null @@ -1,297 +0,0 @@ -import argparse -import logging -import os -import re -from concurrent import futures - -import grpc -import libvirt -from grpc_reflection.v1alpha import reflection -from sqlalchemy import create_engine, event -from sqlalchemy.engine import Engine -from sqlalchemy.orm import sessionmaker -from sqlalchemy.pool import StaticPool - -from minivirt import ( - controller_pb2_grpc, - daemon_pb2_grpc, - dns_pb2_grpc, - domain_pb2, - domain_pb2_grpc, - host_pb2, - host_pb2_grpc, - port_forwarding_pb2_grpc, - route_pb2_grpc, - volume_pb2_grpc, -) -from minivirt.controller import Controller -from minivirt.daemon import DaemonService -from minivirt.dns_controller import DNSController -from minivirt.host import HostController, HostService -from minivirt.migrations import run_migrations -from minivirt.port_forwarding import IPTablesPortForwardingSynchronizer -from minivirt.utils import UnaryUnaryInterceptor -from minivirt.version import __version__ - -libvirt.registerErrorHandler(lambda u, e: None, None) - - -@event.listens_for(Engine, "connect") -def set_sqlite_pragma(dbapi_connection, connection_record): - cursor = dbapi_connection.cursor() - cursor.execute("PRAGMA foreign_keys=ON") - cursor.close() - - -def start_controller(args): - host, port = args.bind - host = host or "0.0.0.0" - - if args.debug: - logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) - - engine = create_engine( - f"sqlite:///{os.path.join(args.config, 'controller.sqlite3')}", - connect_args={"check_same_thread": False}, - poolclass=StaticPool, - future=True, - ) - run_migrations(engine) - session_factory = sessionmaker(engine, future=True) - - dns_controller = DNSController(session_factory) - dns_controller.start(port=5353) - - server = grpc.server( - futures.ThreadPoolExecutor(max_workers=10), interceptors=[UnaryUnaryInterceptor()] - ) - - creds = read_grpc_creds(args.client_ca_cert, args.server_cert, args.server_key) - - host_controller = HostController(session_factory, to_channel_creds(creds)) - controller = Controller( - session_factory=session_factory, - host_controller=host_controller, - dns_controller=dns_controller, - ) - controller_pb2_grpc.add_ControllerServiceServicer_to_server(controller, server) - dns_pb2_grpc.add_DNSServicer_to_server(controller, server) - domain_pb2_grpc.add_DomainServiceServicer_to_server(controller, server) - port_forwarding_pb2_grpc.add_PortForwardingServiceServicer_to_server(controller, server) - route_pb2_grpc.add_RouteServiceServicer_to_server(controller, server) - volume_pb2_grpc.add_VolumeServiceServicer_to_server(controller, server) - host_pb2_grpc.add_HostServiceServicer_to_server( - HostService(host_controller, session_factory), server - ) - - server.add_secure_port(f"{host}:{port}", to_server_creds(creds)) - reflection.enable_server_reflection( - [ - service_descriptor.full_name - for service_descriptor in domain_pb2.DESCRIPTOR.services_by_name.values() - ] - + [reflection.SERVICE_NAME], - server, - ) - - logging.info(f"Starting Controller ({__version__})") - server.start() - server.wait_for_termination() - - -def read_grpc_creds(ca_cert_path, cert_path, key_path): - with ( - open(ca_cert_path, "rb") as ca_cert, - open(cert_path, "rb") as cert, - open(key_path, "rb") as key, - ): - root_certificate = ca_cert.read() - certificate_chain = cert.read() - private_key = key.read() - - return (root_certificate, certificate_chain, private_key) - - -def to_channel_creds(triple): - (root_certificate, certificate_chain, private_key) = triple - return grpc.ssl_channel_credentials( - root_certificates=root_certificate, - certificate_chain=certificate_chain, - private_key=private_key, - ) - - -def to_server_creds(triple): - (root_certificate, certificate_chain, private_key) = triple - return grpc.ssl_server_credentials( - [(private_key, certificate_chain)], - root_certificates=root_certificate, - require_client_auth=True, - ) - - -def get_controller_channel(args): - controller_host, controller_port = args.controller - client_key_pair_provided = args.client_cert is not None and args.client_key is not None - - assert args.server_ca_cert is not None - assert client_key_pair_provided - - return grpc.secure_channel( - f"{controller_host}:{controller_port}", - to_channel_creds(read_grpc_creds(args.server_ca_cert, args.client_cert, args.client_key)), - ) - - -def start_daemon(args): - addr, port = args.bind - port = port or 0 - addr = addr or "0.0.0.0" - - if args.debug: - logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) - - engine = create_engine( - f"sqlite:///{os.path.join(args.config, 'daemon.sqlite3')}", - connect_args={"check_same_thread": False}, - poolclass=StaticPool, - future=True, - ) - run_migrations(engine) - session_factory = sessionmaker(engine, future=True) - - daemon = grpc.server( - futures.ThreadPoolExecutor(max_workers=10), interceptors=[UnaryUnaryInterceptor()] - ) - daemon.add_secure_port( - f"{addr}:{port}", - to_server_creds(read_grpc_creds(args.server_ca_cert, args.client_cert, args.client_key)), - ) - - controller_channel = get_controller_channel(args) - - daemon_service = DaemonService( - session_factory, - IPTablesPortForwardingSynchronizer( - controller_pb2_grpc.ControllerServiceStub(controller_channel), - args.dns_server, - ), - controller_channel, - ) - daemon_pb2_grpc.add_DaemonServiceServicer_to_server(daemon_service, daemon) - daemon_service.sync() - - logging.info(f"Starting Daemon ({__version__})") - daemon.start() - daemon.wait_for_termination() - - -def register_host(args): - addr, port = args.bind - port = port or 0 - addr = addr or "0.0.0.0" - - controller_channel = get_controller_channel(args) - - host_client = host_pb2_grpc.HostServiceStub(controller_channel) - token = host_client.CreateBootstrapToken(host_pb2.CreateBootstrapTokenRequest()).token - host_client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name=args.name, - address=f"{addr}:{port}", - ), - ) - ) - - logging.info(f"Successfully registered host ({__version__})") - - -def deregister_host(args): - controller_channel = get_controller_channel(args) - - host_client = host_pb2_grpc.HostServiceStub(controller_channel) - host_client.Deregister(host_pb2.Host(name=args.name)) - - logging.info(f"Successfully deregistered host ({__version__})") - - -def main(): - logging.basicConfig( - level=logging.DEBUG, format="%(asctime)s %(levelname)s:%(name)s:%(message)s" - ) - - p = re.compile(r"^(\S*):(\d+)$") - - def bind_address(s): - match = p.match(s) - if not match: - raise argparse.ArgumentTypeError("invalid bind address: " + s) - res = match.group(1), int(match.group(2)) - return res - - parser = argparse.ArgumentParser( - description="restvirt", formatter_class=argparse.ArgumentDefaultsHelpFormatter - ) - subparsers = parser.add_subparsers() - - controller_parser = subparsers.add_parser("controller") - controller_parser.add_argument("--debug", action="store_true", help="run in debug mode") - controller_parser.add_argument( - "-b", "--bind", type=bind_address, default=":8090", help="controller bind address" - ) - controller_parser.add_argument( - "-c", "--config", default="/etc/restvirt", help="configuration folder" - ) - controller_parser.add_argument("--server-cert") - controller_parser.add_argument("--server-key") - controller_parser.add_argument("--client-ca-cert") - controller_parser.set_defaults(func=start_controller) - - daemon_parser = subparsers.add_parser("daemon") - daemon_parser.add_argument("--name", default="default", help="host's name") - daemon_parser.add_argument("--debug", action="store_true", help="run in debug mode") - daemon_parser.add_argument("--dns-server", help="custom DNS server") - daemon_parser.add_argument( - "-b", "--bind", type=bind_address, default="127.0.0.1:8099", help="daemon bind address" - ) - daemon_parser.add_argument( - "-a", "--controller", type=bind_address, default="127.0.0.1:8094", help="controller address" - ) - daemon_parser.add_argument( - "-c", "--config", default="/etc/restvirt", help="configuration folder" - ) - daemon_parser.add_argument("--client-cert") - daemon_parser.add_argument("--client-key") - daemon_parser.add_argument("--server-ca-cert") - daemon_parser.set_defaults(func=start_daemon) - - register_parser = subparsers.add_parser("register") - register_parser.add_argument("--name", help="host's name") - register_parser.add_argument("-b", "--bind", type=bind_address, help="daemon bind address") - register_parser.add_argument( - "-a", "--controller", type=bind_address, default="127.0.0.1:8094", help="controller address" - ) - register_parser.add_argument("--client-cert") - register_parser.add_argument("--client-key") - register_parser.add_argument("--server-ca-cert") - register_parser.set_defaults(func=register_host) - - deregister_parser = subparsers.add_parser("deregister") - deregister_parser.add_argument("--name", help="host's name") - deregister_parser.add_argument( - "-a", "--controller", type=bind_address, default="127.0.0.1:8094", help="controller address" - ) - deregister_parser.add_argument("--client-cert") - deregister_parser.add_argument("--client-key") - deregister_parser.add_argument("--server-ca-cert") - deregister_parser.set_defaults(func=deregister_host) - - args = parser.parse_args() - logging.debug(args) - args.func(args) - - -if __name__ == "__main__": - main() diff --git a/minivirt/migrations.py b/minivirt/migrations.py deleted file mode 100644 index c281f13..0000000 --- a/minivirt/migrations.py +++ /dev/null @@ -1,116 +0,0 @@ -import itertools -import sqlite3 - -import sqlalchemy as sa - - -def _migration_0(engine): - with engine.connect() as conn: - conn.connection.executescript( - """ -BEGIN; - -ALTER TABLE domains ADD ipv6_address VARCHAR; -ALTER TABLE networks ADD cidr6 VARCHAR; - -DELETE FROM versions; -INSERT INTO versions VALUES('1'); - -COMMIT; -""" - ) - - -migrations = { - "0": _migration_0, -} - - -def run_migrations(engine: sa.engine.Engine): - create_initial(engine) - - with engine.connect() as conn: - connection = conn.connection - connection.row_factory = sqlite3.Row - cur = connection.cursor() - cur.row_factory = sqlite3.Row - try: - cur.execute("SELECT * FROM versions") - res = cur.fetchall() - assert len(res) == 1 - version = res[0]["version"] - finally: - cur.close() - - for key in itertools.dropwhile(lambda k: k != version, migrations): - print(f'Executing migration from version "{key}"') - migration_func = migrations[key] - migration_func(engine) - - -def create_initial(engine): - with engine.connect() as conn: - conn.connection.executescript( - """ -CREATE TABLE IF NOT EXISTS bootstrap_tokens ( - token VARCHAR NOT NULL, - expires_at DATETIME, - PRIMARY KEY (token) -); - -CREATE TABLE IF NOT EXISTS hosts ( - name VARCHAR NOT NULL, - address VARCHAR, - last_heartbeat DATETIME, - PRIMARY KEY (name) -); - -CREATE TABLE IF NOT EXISTS networks ( - id VARCHAR NOT NULL, - cidr VARCHAR, - PRIMARY KEY (id) -); - -CREATE TABLE IF NOT EXISTS route_tables ( - id INTEGER NOT NULL, - name VARCHAR, - PRIMARY KEY (id) -); - -CREATE TABLE IF NOT EXISTS port_forwardings ( - protocol VARCHAR NOT NULL, - source_port INTEGER NOT NULL, - target_ip VARCHAR, - target_port INTEGER, - PRIMARY KEY (protocol, source_port) -); - -CREATE TABLE IF NOT EXISTS dns_records ( - name VARCHAR NOT NULL, - type VARCHAR NOT NULL, - ttl INTEGER, - records VARCHAR, - PRIMARY KEY (name, type) -); - -CREATE TABLE IF NOT EXISTS domains ( - id VARCHAR NOT NULL, - private_ip VARCHAR, - os_type VARCHAR, - user_data TEXT, - PRIMARY KEY (id), - UNIQUE (private_ip) -); - -CREATE TABLE IF NOT EXISTS routes ( - destination VARCHAR NOT NULL, - gateways VARCHAR, - route_table_id INTEGER, - PRIMARY KEY (destination), - FOREIGN KEY(route_table_id) REFERENCES route_tables (id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS versions (version VARCHAR); -INSERT INTO versions SELECT '0' WHERE NOT EXISTS (SELECT * FROM versions); -""" - ) diff --git a/minivirt/models.py b/minivirt/models.py deleted file mode 100644 index 79cd2a9..0000000 --- a/minivirt/models.py +++ /dev/null @@ -1,132 +0,0 @@ -from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Text, TypeDecorator, Unicode -from sqlalchemy.orm import backref, registry, relationship - - -class StringList(TypeDecorator): - impl = Unicode - cache_ok = True - - def __init__(self, delimiter=","): - self.delimiter = delimiter - super().__init__() - - def process_bind_param(self, value, dialect): - assert all([self.delimiter not in e for e in value]) - return self.delimiter.join(value) - - def process_result_value(self, value, dialect): - return value.split(self.delimiter) - - -class StringSet(TypeDecorator): - impl = Unicode - cache_ok = True - - def __init__(self, delimiter=","): - self.delimiter = delimiter - super().__init__() - - def process_bind_param(self, value, dialect): - assert isinstance(value, set) - assert all([self.delimiter not in e for e in value]) - return self.delimiter.join(sorted(value)) - - def process_result_value(self, value, dialect): - return set(value.split(self.delimiter)) - - -mapper_registry = registry() -Base = mapper_registry.generate_base() - - -class BootstrapToken(Base): - __tablename__ = "bootstrap_tokens" - - token = Column(String, primary_key=True) - expires_at = Column(DateTime) - - def __repr__(self): - return f"BootstrapToken(token={self.token!r}, expires_at={self.expires_at!r})" - - -class Host(Base): - __tablename__ = "hosts" - - name = Column(String, primary_key=True) - address = Column(String) - last_heartbeat = Column(DateTime) - - def __repr__(self): - return f"Host(name={self.name!r}, address={self.address!r})" - - -class Network(Base): - __tablename__ = "networks" - - id = Column(String, primary_key=True) - cidr = Column(String) - cidr6 = Column(String) - - def __repr__(self): - return f"Network({self.id!r}: {self.cidr!r} {self.cidr6!r})" - - -class RouteTable(Base): - __tablename__ = "route_tables" - - id = Column(Integer, primary_key=True) - name = Column(String) - - def __repr__(self): - return f"RouteTable(id={self.id!r}, name={self.name!r})" - - -class Route(Base): - __tablename__ = "routes" - - destination = Column(String, primary_key=True) - gateways = Column(StringSet) - route_table_id = Column(Integer, ForeignKey("route_tables.id", ondelete="CASCADE")) - route_table = relationship( - "RouteTable", backref=backref("routes", cascade="all, delete-orphan", passive_deletes=True) - ) - - def __repr__(self): - return f"Route(dest={self.destination!r}, gateways={self.gateways!r}, table={self.route_table!r})" - - -class PortForwarding(Base): - __tablename__ = "port_forwardings" - - protocol = Column(String, primary_key=True) - source_port = Column(Integer, primary_key=True) - target_ip = Column(String) - target_port = Column(Integer) - - def __repr__(self): - return f"{self.protocol} :{self.source_port} -> {self.target_ip}:{self.target_port}" - - -class DNSRecord(Base): - __tablename__ = "dns_records" - - name = Column(String, primary_key=True) - type = Column(String, primary_key=True) - ttl = Column(Integer) - records = Column(StringList) - - def __repr__(self): - return f"DNSEntry({self.name} {self.type} {self.ttl} {' '.join(self.records)}" - - -class Domain(Base): - __tablename__ = "domains" - - id = Column(String, primary_key=True) - private_ip = Column(String, unique=True) - ipv6_address = Column(String, unique=True) - os_type = Column(String) - user_data = Column(Text) - - def __repr__(self): - return f"Domain(id={self.id} private_ip={self.private_ip} ipv6_address={self.ipv6_address})" diff --git a/minivirt/port_forwarding.py b/minivirt/port_forwarding.py deleted file mode 100644 index f9095c5..0000000 --- a/minivirt/port_forwarding.py +++ /dev/null @@ -1,301 +0,0 @@ -import ipaddress -import threading - -import libvirt -import nftables -from sqlalchemy import select - -from minivirt import domain_pb2 -from minivirt.daemon import _network_to_pb -from minivirt.models import PortForwarding - - -class IPTablesPortForwardingSynchronizer: - def __init__(self, controller, dns_addr=None): - self.controller = controller - self.lock = threading.Lock() - self.dns_addr = dns_addr - - def handle_sync(self, session, libvirt_conn: libvirt.virConnect): - with self.lock: - forwardings = session.execute(select(PortForwarding).filter()).scalars().all() - - table_name = "restvirt" - - nft = nftables.Nftables() - nft.set_json_output(True) - - rfc1918_nets = [ - { - "prefix": { - "addr": str(net.network_address), - "len": net.prefixlen, - } - } - for net in [ - ipaddress.ip_network(n) - for n in ["192.168.0.0/16", "172.16.0.0/12", "10.0.0.0/8"] - ] - ] - commands = [ - {"add": {"table": {"name": table_name, "family": "inet"}}}, - {"delete": {"table": {"name": table_name, "family": "inet"}}}, - {"add": {"table": {"name": table_name, "family": "inet"}}}, - { - "add": { - "chain": { - "table": table_name, - "family": "inet", - "name": "output", - "type": "nat", - "hook": "output", - "prio": -105, - "policy": "accept", - } - } - }, - { - "add": { - "chain": { - "table": table_name, - "family": "inet", - "name": "prerouting", - "type": "nat", - "hook": "prerouting", - "prio": -105, - "policy": "accept", - } - } - }, - { - "add": { - "chain": { - "table": table_name, - "family": "inet", - "name": "postrouting", - "type": "nat", - "hook": "postrouting", - "prio": 95, - "policy": "accept", - } - } - }, - { - "add": { - "chain": { - "table": table_name, - "family": "inet", - "name": "forward", - "type": "filter", - "hook": "forward", - "prio": -5, - "policy": "accept", - } - } - }, - { - "add": { # ensure rfc1918 rules - "rule": { - "table": table_name, - "family": "inet", - "chain": "postrouting", - "expr": [ - { - "match": { - "op": "in", - "left": {"payload": {"protocol": "ip", "field": "saddr"}}, - "right": {"set": rfc1918_nets}, - } - }, - { - "match": { - "op": "!=", - "left": {"payload": {"protocol": "ip", "field": "daddr"}}, - "right": {"set": rfc1918_nets}, - } - }, - { - "counter": None, - }, - {"masquerade": None}, - ], - } - } - }, - ] - - # FIXME: limit to eno2 src port - for f in forwardings: - commands.extend( - [ - { - "add": { - "rule": { - "table": table_name, - "family": "inet", - "chain": "output", - "expr": [ - { - "match": { - "op": "==", - "left": { - "payload": { - "protocol": f.protocol, - "field": "dport", - } - }, - "right": f.source_port, - } - }, - { - "counter": None, - }, - { - "dnat": { - "family": "ip", - "addr": f.target_ip, - "port": f.target_port, - } - }, - ], - } - } - }, - { - "add": { - "rule": { - "table": table_name, - "family": "inet", - "chain": "prerouting", - "expr": [ - { - "match": { - "op": "==", - "left": { - "payload": { - "protocol": f.protocol, - "field": "dport", - } - }, - "right": f.source_port, - } - }, - { - "counter": None, - }, - { - "dnat": { - "family": "ip", - "addr": f.target_ip, - "port": f.target_port, - } - }, - ], - } - } - }, - { - "add": { - "rule": { - "table": table_name, - "family": "inet", - "chain": "forward", - "expr": [ - { - "match": { - "op": "==", - "left": { - "payload": { - "protocol": f.protocol, - "field": "dport", - } - }, - "right": f.target_port, - } - }, - { - "match": { - "op": "==", - "left": { - "payload": {"protocol": "ip", "field": "daddr"} - }, - "right": f.target_ip, - } - }, - { - "counter": None, - }, - {"accept": None}, - ], - } - } - }, - ] - ) - - networks = [_network_to_pb(net) for net in libvirt_conn.listAllNetworks()] - for network in networks: - net = ipaddress.IPv4Network(network.cidr) - - dns_addr = self.dns_addr - if self.dns_addr is None: - dns_addr = str(net[1]) - - for chain in ["output", "prerouting"]: - for protocol in ["udp", "tcp"]: - commands.extend( - [ - { - "add": { # FIXME: use configurable target IP:port - "rule": { - "table": table_name, - "family": "inet", - "chain": chain, - "expr": [ - { - "match": { - "op": "==", - "left": { - "payload": { - "protocol": protocol, - "field": "dport", - } - }, - "right": 53, - } - }, - { - "match": { - "op": "==", - "left": { - "payload": { - "protocol": "ip", - "field": "daddr", - } - }, - "right": str(net[1]), - } - }, - { - "counter": None, - }, - { - "dnat": { - "family": "ip", - "addr": dns_addr, - "port": 5354, - } - }, - ], - } - } - }, - ] - ) - - rc, output, error = nft.json_cmd({"nftables": commands}) - # FIXME: replace with logging - print(rc) - print(output) - print(error) - assert rc == 0 diff --git a/minivirt/port_forwarding_pb2.py b/minivirt/port_forwarding_pb2.py deleted file mode 100644 index 868b34d..0000000 --- a/minivirt/port_forwarding_pb2.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/port_forwarding.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1eminivirt/port_forwarding.proto\x1a\x1bgoogle/protobuf/empty.proto\"O\n\x18PortForwardingIdentifier\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x10\n\x08protocol\x18\x02 \x01(\t\x12\x13\n\x0bsource_port\x18\x03 \x01(\r\"_\n\x0ePortForwarding\x12\x10\n\x08protocol\x18\x02 \x01(\t\x12\x13\n\x0bsource_port\x18\x03 \x01(\r\x12\x11\n\ttarget_ip\x18\x04 \x01(\t\x12\x13\n\x0btarget_port\x18\x05 \x01(\r\"*\n\x1aListPortForwardingsRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\"H\n\x1bListPortForwardingsResponse\x12)\n\x10port_forwardings\x18\x01 \x03(\x0b\x32\x0f.PortForwarding\"R\n\x18PutPortForwardingRequest\x12(\n\x0fport_forwarding\x18\x01 \x01(\x0b\x32\x0f.PortForwarding\x12\x0c\n\x04host\x18\x02 \x01(\t2\xbe\x02\n\x15PortForwardingService\x12\x41\n\x11GetPortForwarding\x12\x19.PortForwardingIdentifier\x1a\x0f.PortForwarding\"\x00\x12R\n\x13ListPortForwardings\x12\x1b.ListPortForwardingsRequest\x1a\x1c.ListPortForwardingsResponse\"\x00\x12\x41\n\x11PutPortForwarding\x12\x19.PutPortForwardingRequest\x1a\x0f.PortForwarding\"\x00\x12K\n\x14\x44\x65letePortForwarding\x12\x19.PortForwardingIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.port_forwarding_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _PORTFORWARDINGIDENTIFIER._serialized_start=63 - _PORTFORWARDINGIDENTIFIER._serialized_end=142 - _PORTFORWARDING._serialized_start=144 - _PORTFORWARDING._serialized_end=239 - _LISTPORTFORWARDINGSREQUEST._serialized_start=241 - _LISTPORTFORWARDINGSREQUEST._serialized_end=283 - _LISTPORTFORWARDINGSRESPONSE._serialized_start=285 - _LISTPORTFORWARDINGSRESPONSE._serialized_end=357 - _PUTPORTFORWARDINGREQUEST._serialized_start=359 - _PUTPORTFORWARDINGREQUEST._serialized_end=441 - _PORTFORWARDINGSERVICE._serialized_start=444 - _PORTFORWARDINGSERVICE._serialized_end=762 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/port_forwarding_pb2_grpc.py b/minivirt/port_forwarding_pb2_grpc.py deleted file mode 100644 index 0441b5d..0000000 --- a/minivirt/port_forwarding_pb2_grpc.py +++ /dev/null @@ -1,166 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import port_forwarding_pb2 as minivirt_dot_port__forwarding__pb2 - - -class PortForwardingServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetPortForwarding = channel.unary_unary( - '/PortForwardingService/GetPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.ListPortForwardings = channel.unary_unary( - '/PortForwardingService/ListPortForwardings', - request_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - ) - self.PutPortForwarding = channel.unary_unary( - '/PortForwardingService/PutPortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - response_deserializer=minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - ) - self.DeletePortForwarding = channel.unary_unary( - '/PortForwardingService/DeletePortForwarding', - request_serializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class PortForwardingServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListPortForwardings(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutPortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeletePortForwarding(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_PortForwardingServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.GetPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'ListPortForwardings': grpc.unary_unary_rpc_method_handler( - servicer.ListPortForwardings, - request_deserializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.SerializeToString, - ), - 'PutPortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.PutPortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.FromString, - response_serializer=minivirt_dot_port__forwarding__pb2.PortForwarding.SerializeToString, - ), - 'DeletePortForwarding': grpc.unary_unary_rpc_method_handler( - servicer.DeletePortForwarding, - request_deserializer=minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'PortForwardingService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class PortForwardingService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/PortForwardingService/GetPortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListPortForwardings(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/PortForwardingService/ListPortForwardings', - minivirt_dot_port__forwarding__pb2.ListPortForwardingsRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.ListPortForwardingsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutPortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/PortForwardingService/PutPortForwarding', - minivirt_dot_port__forwarding__pb2.PutPortForwardingRequest.SerializeToString, - minivirt_dot_port__forwarding__pb2.PortForwarding.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeletePortForwarding(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/PortForwardingService/DeletePortForwarding', - minivirt_dot_port__forwarding__pb2.PortForwardingIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/route.py b/minivirt/route.py deleted file mode 100644 index a336eee..0000000 --- a/minivirt/route.py +++ /dev/null @@ -1,133 +0,0 @@ -import ipaddress -from typing import Dict, Set - -from sqlalchemy import delete, select - -from minivirt import route_pb2 -from minivirt.models import Route, RouteTable - - -class SyncEventHandler: - def handle_sync(self, session): - pass - - -class GenericRouteTableController: - id_range_min, id_range_max = 30069, 30169 - - def __init__(self, session_factory, sync_handler=SyncEventHandler()): - self.session_factory = session_factory - self.sync_handler = sync_handler - - def route_tables(self): - with self.session_factory() as session: - return session.execute(select(RouteTable)).scalars().all() - - def route_table(self, id): - with self.session_factory() as session: - return ( - session.execute(select(RouteTable).filter(RouteTable.id == id)) - .scalars() - .one_or_none() - ) - - def _get_available_id(self, session): - ids = session.execute(select(RouteTable.id).order_by(RouteTable.id)).scalars().all() - if not ids or ids[0] > self.id_range_min: - return self.id_range_min - for i in range(len(ids) - 1): - if ids[i + 1] - ids[i] > 1: - return ids[i] + 1 - assert ids[-1] < self.id_range_max - return ids[-1] + 1 - - def create_route_table(self, r: route_pb2.RouteTable): - with self.session_factory() as session: - route = RouteTable( - id=self._get_available_id(session), - name=r.name, - ) - session.add(route) - session.commit() - self.sync_handler.handle_sync(session) - - return route_pb2.RouteTable( - id=route.id, - name=route.name, - ) - - def remove_route_table(self, id): - with self.session_factory() as session: - res = session.execute(delete(RouteTable).where(RouteTable.id == id)) - if res.rowcount == 0: - return False - - assert res.rowcount == 1 - session.commit() - self.sync_handler.handle_sync(session) - return True - - def sync(self): - with self.session_factory() as session: - self.sync_handler.handle_sync(session) - - -AliasIPConf = Dict[ipaddress.IPv4Network, Set[ipaddress.IPv4Address]] - -TABLE_ID = 69 - - -class GenericRouteController: - def __init__(self, session_factory, sync_handler=SyncEventHandler()): - self.session_factory = session_factory - self.sync_handler = sync_handler - - def routes(self, route_table_id=None): - with self.session_factory() as session: - return ( - session.execute(select(Route).filter(Route.route_table_id == route_table_id)) - .scalars() - .all() - ) - - def route(self, route_table_id, destination): - with self.session_factory() as session: - return ( - session.execute( - select(Route).filter( - Route.route_table_id == route_table_id, - Route.destination == destination, - ) - ) - .scalars() - .one_or_none() - ) - - def put_route(self, r: route_pb2.Route): - route = Route( - destination=r.destination, - gateways=set(r.gateways), - route_table_id=r.route_table_id, - ) - with self.session_factory() as session: - merged = session.merge(route) - if session.is_modified(merged): - session.commit() - self.sync_handler.handle_sync(session) - - return r - - def remove_route(self, route_table_id, destination): - with self.session_factory() as session: - session.execute( - delete(Route).where( - Route.destination == destination, - Route.route_table_id == route_table_id, - ) - ) - session.commit() - self.sync_handler.handle_sync(session) - - def sync(self): - with self.session_factory() as session: - self.sync_handler.handle_sync(session) diff --git a/minivirt/route_pb2.py b/minivirt/route_pb2.py deleted file mode 100644 index 6133ea9..0000000 --- a/minivirt/route_pb2.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/route.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14minivirt/route.proto\x1a\x1bgoogle/protobuf/empty.proto\"<\n\nRouteTable\x12\x14\n\x0cnetwork_name\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\r\x12\x0c\n\x04name\x18\x03 \x01(\t\"\"\n\x14RouteTableIdentifier\x12\n\n\x02id\x18\x01 \x01(\r\".\n\x16ListRouteTablesRequest\x12\x14\n\x0cnetwork_name\x18\x01 \x01(\t\"<\n\x17ListRouteTablesResponse\x12!\n\x0croute_tables\x18\x01 \x03(\x0b\x32\x0b.RouteTable\";\n\x17\x43reateRouteTableRequest\x12 \n\x0broute_table\x18\x01 \x01(\x0b\x32\x0b.RouteTable\">\n\x0fRouteIdentifier\x12\x16\n\x0eroute_table_id\x18\x01 \x01(\r\x12\x13\n\x0b\x64\x65stination\x18\x02 \x01(\t\"F\n\x05Route\x12\x16\n\x0eroute_table_id\x18\x01 \x01(\r\x12\x13\n\x0b\x64\x65stination\x18\x02 \x01(\t\x12\x10\n\x08gateways\x18\x03 \x03(\t\"+\n\x11ListRoutesRequest\x12\x16\n\x0eroute_table_id\x18\x01 \x01(\r\",\n\x12ListRoutesResponse\x12\x16\n\x06routes\x18\x01 \x03(\x0b\x32\x06.Route\"(\n\x0fPutRouteRequest\x12\x15\n\x05route\x18\x01 \x01(\x0b\x32\x06.Route\"\r\n\x0bSyncRequest2\x83\x04\n\x0cRouteService\x12\x35\n\rGetRouteTable\x12\x15.RouteTableIdentifier\x1a\x0b.RouteTable\"\x00\x12\x46\n\x0fListRouteTables\x12\x17.ListRouteTablesRequest\x1a\x18.ListRouteTablesResponse\"\x00\x12;\n\x10\x43reateRouteTable\x12\x18.CreateRouteTableRequest\x1a\x0b.RouteTable\"\x00\x12\x43\n\x10\x44\x65leteRouteTable\x12\x15.RouteTableIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12&\n\x08GetRoute\x12\x10.RouteIdentifier\x1a\x06.Route\"\x00\x12\x37\n\nListRoutes\x12\x12.ListRoutesRequest\x1a\x13.ListRoutesResponse\"\x00\x12&\n\x08PutRoute\x12\x10.PutRouteRequest\x1a\x06.Route\"\x00\x12\x39\n\x0b\x44\x65leteRoute\x12\x10.RouteIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x12.\n\x04Sync\x12\x0c.SyncRequest\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.route_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _ROUTETABLE._serialized_start=53 - _ROUTETABLE._serialized_end=113 - _ROUTETABLEIDENTIFIER._serialized_start=115 - _ROUTETABLEIDENTIFIER._serialized_end=149 - _LISTROUTETABLESREQUEST._serialized_start=151 - _LISTROUTETABLESREQUEST._serialized_end=197 - _LISTROUTETABLESRESPONSE._serialized_start=199 - _LISTROUTETABLESRESPONSE._serialized_end=259 - _CREATEROUTETABLEREQUEST._serialized_start=261 - _CREATEROUTETABLEREQUEST._serialized_end=320 - _ROUTEIDENTIFIER._serialized_start=322 - _ROUTEIDENTIFIER._serialized_end=384 - _ROUTE._serialized_start=386 - _ROUTE._serialized_end=456 - _LISTROUTESREQUEST._serialized_start=458 - _LISTROUTESREQUEST._serialized_end=501 - _LISTROUTESRESPONSE._serialized_start=503 - _LISTROUTESRESPONSE._serialized_end=547 - _PUTROUTEREQUEST._serialized_start=549 - _PUTROUTEREQUEST._serialized_end=589 - _SYNCREQUEST._serialized_start=591 - _SYNCREQUEST._serialized_end=604 - _ROUTESERVICE._serialized_start=607 - _ROUTESERVICE._serialized_end=1122 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/route_pb2_grpc.py b/minivirt/route_pb2_grpc.py deleted file mode 100644 index f6211f2..0000000 --- a/minivirt/route_pb2_grpc.py +++ /dev/null @@ -1,331 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import route_pb2 as minivirt_dot_route__pb2 - - -class RouteServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetRouteTable = channel.unary_unary( - '/RouteService/GetRouteTable', - request_serializer=minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.RouteTable.FromString, - ) - self.ListRouteTables = channel.unary_unary( - '/RouteService/ListRouteTables', - request_serializer=minivirt_dot_route__pb2.ListRouteTablesRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.ListRouteTablesResponse.FromString, - ) - self.CreateRouteTable = channel.unary_unary( - '/RouteService/CreateRouteTable', - request_serializer=minivirt_dot_route__pb2.CreateRouteTableRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.RouteTable.FromString, - ) - self.DeleteRouteTable = channel.unary_unary( - '/RouteService/DeleteRouteTable', - request_serializer=minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetRoute = channel.unary_unary( - '/RouteService/GetRoute', - request_serializer=minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.Route.FromString, - ) - self.ListRoutes = channel.unary_unary( - '/RouteService/ListRoutes', - request_serializer=minivirt_dot_route__pb2.ListRoutesRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.ListRoutesResponse.FromString, - ) - self.PutRoute = channel.unary_unary( - '/RouteService/PutRoute', - request_serializer=minivirt_dot_route__pb2.PutRouteRequest.SerializeToString, - response_deserializer=minivirt_dot_route__pb2.Route.FromString, - ) - self.DeleteRoute = channel.unary_unary( - '/RouteService/DeleteRoute', - request_serializer=minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.Sync = channel.unary_unary( - '/RouteService/Sync', - request_serializer=minivirt_dot_route__pb2.SyncRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class RouteServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListRouteTables(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteRouteTable(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListRoutes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PutRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteRoute(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Sync(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_RouteServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.GetRouteTable, - request_deserializer=minivirt_dot_route__pb2.RouteTableIdentifier.FromString, - response_serializer=minivirt_dot_route__pb2.RouteTable.SerializeToString, - ), - 'ListRouteTables': grpc.unary_unary_rpc_method_handler( - servicer.ListRouteTables, - request_deserializer=minivirt_dot_route__pb2.ListRouteTablesRequest.FromString, - response_serializer=minivirt_dot_route__pb2.ListRouteTablesResponse.SerializeToString, - ), - 'CreateRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.CreateRouteTable, - request_deserializer=minivirt_dot_route__pb2.CreateRouteTableRequest.FromString, - response_serializer=minivirt_dot_route__pb2.RouteTable.SerializeToString, - ), - 'DeleteRouteTable': grpc.unary_unary_rpc_method_handler( - servicer.DeleteRouteTable, - request_deserializer=minivirt_dot_route__pb2.RouteTableIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetRoute': grpc.unary_unary_rpc_method_handler( - servicer.GetRoute, - request_deserializer=minivirt_dot_route__pb2.RouteIdentifier.FromString, - response_serializer=minivirt_dot_route__pb2.Route.SerializeToString, - ), - 'ListRoutes': grpc.unary_unary_rpc_method_handler( - servicer.ListRoutes, - request_deserializer=minivirt_dot_route__pb2.ListRoutesRequest.FromString, - response_serializer=minivirt_dot_route__pb2.ListRoutesResponse.SerializeToString, - ), - 'PutRoute': grpc.unary_unary_rpc_method_handler( - servicer.PutRoute, - request_deserializer=minivirt_dot_route__pb2.PutRouteRequest.FromString, - response_serializer=minivirt_dot_route__pb2.Route.SerializeToString, - ), - 'DeleteRoute': grpc.unary_unary_rpc_method_handler( - servicer.DeleteRoute, - request_deserializer=minivirt_dot_route__pb2.RouteIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'Sync': grpc.unary_unary_rpc_method_handler( - servicer.Sync, - request_deserializer=minivirt_dot_route__pb2.SyncRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'RouteService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class RouteService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/GetRouteTable', - minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - minivirt_dot_route__pb2.RouteTable.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListRouteTables(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/ListRouteTables', - minivirt_dot_route__pb2.ListRouteTablesRequest.SerializeToString, - minivirt_dot_route__pb2.ListRouteTablesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/CreateRouteTable', - minivirt_dot_route__pb2.CreateRouteTableRequest.SerializeToString, - minivirt_dot_route__pb2.RouteTable.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteRouteTable(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/DeleteRouteTable', - minivirt_dot_route__pb2.RouteTableIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/GetRoute', - minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - minivirt_dot_route__pb2.Route.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListRoutes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/ListRoutes', - minivirt_dot_route__pb2.ListRoutesRequest.SerializeToString, - minivirt_dot_route__pb2.ListRoutesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def PutRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/PutRoute', - minivirt_dot_route__pb2.PutRouteRequest.SerializeToString, - minivirt_dot_route__pb2.Route.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/DeleteRoute', - minivirt_dot_route__pb2.RouteIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Sync(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/RouteService/Sync', - minivirt_dot_route__pb2.SyncRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/minivirt/utils.py b/minivirt/utils.py deleted file mode 100644 index 7e0cd91..0000000 --- a/minivirt/utils.py +++ /dev/null @@ -1,39 +0,0 @@ -import logging -from timeit import default_timer as timer - -import grpc -import libvirt -from google.protobuf import empty_pb2 - - -class UnaryUnaryInterceptor(grpc.ServerInterceptor): - def intercept_service(self, continuation, handler_call_details): - next = continuation(handler_call_details) - if next is None: - return None - if next.unary_unary is None: - return next - - def letsgo(request, context): - start = timer() - try: - response = next.unary_unary(request, context) - except libvirt.libvirtError as e: - status_code = grpc.StatusCode.INTERNAL - if e.get_error_code() in [ - libvirt.VIR_ERR_NO_DOMAIN, - libvirt.VIR_ERR_NO_STORAGE_VOL, - ]: - status_code = grpc.StatusCode.NOT_FOUND - context.set_code(status_code) - context.set_details(f"{e} ({e.get_error_code()})") - response = empty_pb2.Empty() - - logging.debug(f"{handler_call_details.method} [{(timer() - start)*1000:.3f} ms]") - return response - - return grpc.unary_unary_rpc_method_handler( - letsgo, - request_deserializer=next.request_deserializer, - response_serializer=next.response_serializer, - ) diff --git a/minivirt/version.py b/minivirt/version.py deleted file mode 100644 index d5cfca6..0000000 --- a/minivirt/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "unknown" diff --git a/minivirt/volume_pb2.py b/minivirt/volume_pb2.py deleted file mode 100644 index 84b8819..0000000 --- a/minivirt/volume_pb2.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: minivirt/volume.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15minivirt/volume.proto\x1a\x1bgoogle/protobuf/empty.proto\".\n\x10GetVolumeRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"0\n\x06Volume\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0c\n\x04size\x18\x03 \x01(\x04\"\"\n\x12ListVolumesRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\"/\n\x13ListVolumesResponse\x12\x18\n\x07volumes\x18\x01 \x03(\x0b\x32\x07.Volume\"<\n\x13\x43reateVolumeRequest\x12\x17\n\x06volume\x18\x01 \x01(\x0b\x32\x07.Volume\x12\x0c\n\x04host\x18\x02 \x01(\t\"<\n\x13UpdateVolumeRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x17\n\x06volume\x18\x02 \x01(\x0b\x32\x07.Volume\"1\n\x13\x44\x65leteVolumeRequest\x12\x0c\n\x04uuid\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"P\n\x1aVolumeAttachmentIdentifier\x12\x11\n\tdomain_id\x18\x01 \x01(\t\x12\x11\n\tvolume_id\x18\x02 \x01(\t\x12\x0c\n\x04host\x18\x03 \x01(\t\"N\n\x10VolumeAttachment\x12\x11\n\tdomain_id\x18\x01 \x01(\t\x12\x11\n\tvolume_id\x18\x02 \x01(\t\x12\x14\n\x0c\x64isk_address\x18\x03 \x01(\t\"?\n\x1cListVolumeAttachmentsRequest\x12\x11\n\tdomain_id\x18\x01 \x01(\t\x12\x0c\n\x04host\x18\x02 \x01(\t\"G\n\x1dListVolumeAttachmentsResponse\x12&\n\x0b\x61ttachments\x18\x01 \x03(\x0b\x32\x11.VolumeAttachment2\xc4\x04\n\rVolumeService\x12)\n\tGetVolume\x12\x11.GetVolumeRequest\x1a\x07.Volume\"\x00\x12:\n\x0bListVolumes\x12\x13.ListVolumesRequest\x1a\x14.ListVolumesResponse\"\x00\x12/\n\x0c\x43reateVolume\x12\x14.CreateVolumeRequest\x1a\x07.Volume\"\x00\x12/\n\x0cUpdateVolume\x12\x14.UpdateVolumeRequest\x1a\x07.Volume\"\x00\x12>\n\x0c\x44\x65leteVolume\x12\x14.DeleteVolumeRequest\x1a\x16.google.protobuf.Empty\"\x00\x12X\n\x15ListVolumeAttachments\x12\x1d.ListVolumeAttachmentsRequest\x1a\x1e.ListVolumeAttachmentsResponse\"\x00\x12G\n\x13GetVolumeAttachment\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12@\n\x0c\x41ttachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x11.VolumeAttachment\"\x00\x12\x45\n\x0c\x44\x65tachVolume\x12\x1b.VolumeAttachmentIdentifier\x1a\x16.google.protobuf.Empty\"\x00\x42\x06Z\x04.;pbb\x06proto3') - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'minivirt.volume_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\004.;pb' - _GETVOLUMEREQUEST._serialized_start=54 - _GETVOLUMEREQUEST._serialized_end=100 - _VOLUME._serialized_start=102 - _VOLUME._serialized_end=150 - _LISTVOLUMESREQUEST._serialized_start=152 - _LISTVOLUMESREQUEST._serialized_end=186 - _LISTVOLUMESRESPONSE._serialized_start=188 - _LISTVOLUMESRESPONSE._serialized_end=235 - _CREATEVOLUMEREQUEST._serialized_start=237 - _CREATEVOLUMEREQUEST._serialized_end=297 - _UPDATEVOLUMEREQUEST._serialized_start=299 - _UPDATEVOLUMEREQUEST._serialized_end=359 - _DELETEVOLUMEREQUEST._serialized_start=361 - _DELETEVOLUMEREQUEST._serialized_end=410 - _VOLUMEATTACHMENTIDENTIFIER._serialized_start=412 - _VOLUMEATTACHMENTIDENTIFIER._serialized_end=492 - _VOLUMEATTACHMENT._serialized_start=494 - _VOLUMEATTACHMENT._serialized_end=572 - _LISTVOLUMEATTACHMENTSREQUEST._serialized_start=574 - _LISTVOLUMEATTACHMENTSREQUEST._serialized_end=637 - _LISTVOLUMEATTACHMENTSRESPONSE._serialized_start=639 - _LISTVOLUMEATTACHMENTSRESPONSE._serialized_end=710 - _VOLUMESERVICE._serialized_start=713 - _VOLUMESERVICE._serialized_end=1293 -# @@protoc_insertion_point(module_scope) diff --git a/minivirt/volume_pb2_grpc.py b/minivirt/volume_pb2_grpc.py deleted file mode 100644 index 3c41da1..0000000 --- a/minivirt/volume_pb2_grpc.py +++ /dev/null @@ -1,331 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 -from minivirt import volume_pb2 as minivirt_dot_volume__pb2 - - -class VolumeServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetVolume = channel.unary_unary( - '/VolumeService/GetVolume', - request_serializer=minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.ListVolumes = channel.unary_unary( - '/VolumeService/ListVolumes', - request_serializer=minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - ) - self.CreateVolume = channel.unary_unary( - '/VolumeService/CreateVolume', - request_serializer=minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.UpdateVolume = channel.unary_unary( - '/VolumeService/UpdateVolume', - request_serializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.Volume.FromString, - ) - self.DeleteVolume = channel.unary_unary( - '/VolumeService/DeleteVolume', - request_serializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.ListVolumeAttachments = channel.unary_unary( - '/VolumeService/ListVolumeAttachments', - request_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - ) - self.GetVolumeAttachment = channel.unary_unary( - '/VolumeService/GetVolumeAttachment', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.AttachVolume = channel.unary_unary( - '/VolumeService/AttachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=minivirt_dot_volume__pb2.VolumeAttachment.FromString, - ) - self.DetachVolume = channel.unary_unary( - '/VolumeService/DetachVolume', - request_serializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class VolumeServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumes(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UpdateVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListVolumeAttachments(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetVolumeAttachment(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def AttachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DetachVolume(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_VolumeServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetVolume': grpc.unary_unary_rpc_method_handler( - servicer.GetVolume, - request_deserializer=minivirt_dot_volume__pb2.GetVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'ListVolumes': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumes, - request_deserializer=minivirt_dot_volume__pb2.ListVolumesRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumesResponse.SerializeToString, - ), - 'CreateVolume': grpc.unary_unary_rpc_method_handler( - servicer.CreateVolume, - request_deserializer=minivirt_dot_volume__pb2.CreateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'UpdateVolume': grpc.unary_unary_rpc_method_handler( - servicer.UpdateVolume, - request_deserializer=minivirt_dot_volume__pb2.UpdateVolumeRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.Volume.SerializeToString, - ), - 'DeleteVolume': grpc.unary_unary_rpc_method_handler( - servicer.DeleteVolume, - request_deserializer=minivirt_dot_volume__pb2.DeleteVolumeRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'ListVolumeAttachments': grpc.unary_unary_rpc_method_handler( - servicer.ListVolumeAttachments, - request_deserializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.FromString, - response_serializer=minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.SerializeToString, - ), - 'GetVolumeAttachment': grpc.unary_unary_rpc_method_handler( - servicer.GetVolumeAttachment, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'AttachVolume': grpc.unary_unary_rpc_method_handler( - servicer.AttachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=minivirt_dot_volume__pb2.VolumeAttachment.SerializeToString, - ), - 'DetachVolume': grpc.unary_unary_rpc_method_handler( - servicer.DetachVolume, - request_deserializer=minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'VolumeService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class VolumeService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/GetVolume', - minivirt_dot_volume__pb2.GetVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumes(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/ListVolumes', - minivirt_dot_volume__pb2.ListVolumesRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumesResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def CreateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/CreateVolume', - minivirt_dot_volume__pb2.CreateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def UpdateVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/UpdateVolume', - minivirt_dot_volume__pb2.UpdateVolumeRequest.SerializeToString, - minivirt_dot_volume__pb2.Volume.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DeleteVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/DeleteVolume', - minivirt_dot_volume__pb2.DeleteVolumeRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ListVolumeAttachments(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/ListVolumeAttachments', - minivirt_dot_volume__pb2.ListVolumeAttachmentsRequest.SerializeToString, - minivirt_dot_volume__pb2.ListVolumeAttachmentsResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def GetVolumeAttachment(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/GetVolumeAttachment', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def AttachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/AttachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - minivirt_dot_volume__pb2.VolumeAttachment.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DetachVolume(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/VolumeService/DetachVolume', - minivirt_dot_volume__pb2.VolumeAttachmentIdentifier.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/protos/minivirt/controller.proto b/protos/minivirt/controller.proto deleted file mode 100644 index fe4120d..0000000 --- a/protos/minivirt/controller.proto +++ /dev/null @@ -1,60 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; -import "minivirt/daemon.proto"; -import "minivirt/domain.proto"; -import "minivirt/volume.proto"; -import "minivirt/port_forwarding.proto"; -import "minivirt/dns.proto"; -import "minivirt/route.proto"; - -service ControllerService { - rpc GetDNSRecord(DNSRecordIdentifier) returns (DNSRecord) {} - rpc ListDNSRecords(ListDNSRecordsRequest) returns (ListDNSRecordsResponse) {} - rpc PutDNSRecord(PutDNSRecordRequest) returns (DNSRecord) {} - rpc DeleteDNSRecord(DNSRecordIdentifier) returns (google.protobuf.Empty) {} - - rpc GetNetwork(GetNetworkRequest) returns (Network) {} - rpc ListNetworks(ListNetworksRequest) returns (ListNetworksResponse) {} - rpc CreateNetwork(CreateNetworkRequest) returns (Network) {} - rpc DeleteNetwork(DeleteNetworkRequest) returns (google.protobuf.Empty) {} - - rpc StartDomain(StartDomainRequest) returns (google.protobuf.Empty) {} - rpc StopDomain(StopDomainRequest) returns (google.protobuf.Empty) {} - rpc GetDomain(GetDomainRequest) returns (Domain) {} - rpc ListDomains(ListDomainsRequest) returns (ListDomainsResponse) {} - rpc CreateDomain(CreateDomainRequest) returns (Domain) {} - rpc DeleteDomain(DeleteDomainRequest) returns (google.protobuf.Empty) {} - - rpc DownloadImage(DownloadImageRequest) returns (stream ImageChunk) {} - - rpc GetVolume(GetVolumeRequest) returns (Volume) {} - rpc ListVolumes(ListVolumesRequest) returns (ListVolumesResponse) {} - rpc CreateVolume(CreateVolumeRequest) returns (Volume) {} - rpc UpdateVolume(UpdateVolumeRequest) returns (Volume) {} - rpc DeleteVolume(DeleteVolumeRequest) returns (google.protobuf.Empty) {} - - rpc ListVolumeAttachments(ListVolumeAttachmentsRequest) returns (ListVolumeAttachmentsResponse) {} - rpc GetVolumeAttachment(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc AttachVolume(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc DetachVolume(VolumeAttachmentIdentifier) returns (google.protobuf.Empty) {} - - rpc GetPortForwarding(PortForwardingIdentifier) returns (PortForwarding) {} - rpc ListPortForwardings(ListPortForwardingsRequest) returns (ListPortForwardingsResponse) {} - rpc PutPortForwarding(PutPortForwardingRequest) returns (PortForwarding) {} - rpc DeletePortForwarding(PortForwardingIdentifier) returns (google.protobuf.Empty) {} - - rpc GetRouteTable(RouteTableIdentifier) returns (RouteTable) {} - rpc ListRouteTables(ListRouteTablesRequest) returns (ListRouteTablesResponse) {} - rpc CreateRouteTable(CreateRouteTableRequest) returns (RouteTable) {} - rpc DeleteRouteTable(RouteTableIdentifier) returns (google.protobuf.Empty) {} - - rpc GetRoute(RouteIdentifier) returns (Route) {} - rpc ListRoutes(ListRoutesRequest) returns (ListRoutesResponse) {} - rpc PutRoute(PutRouteRequest) returns (Route) {} - rpc DeleteRoute(RouteIdentifier) returns (google.protobuf.Empty) {} - - rpc SyncRoutes(SyncRoutesRequest) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/daemon.proto b/protos/minivirt/daemon.proto deleted file mode 100644 index 93dc9b9..0000000 --- a/protos/minivirt/daemon.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; -import "minivirt/domain.proto"; -import "minivirt/volume.proto"; -import "minivirt/port_forwarding.proto"; - -message SyncRoutesRequest {} - -service DaemonService { - rpc GetNetwork(GetNetworkRequest) returns (Network) {} - rpc ListNetworks(ListNetworksRequest) returns (ListNetworksResponse) {} - rpc CreateNetwork(CreateNetworkRequest) returns (Network) {} - rpc DeleteNetwork(DeleteNetworkRequest) returns (google.protobuf.Empty) {} - - rpc StartDomain(StartDomainRequest) returns (google.protobuf.Empty) {} - rpc StopDomain(StopDomainRequest) returns (google.protobuf.Empty) {} - rpc GetDomain(GetDomainRequest) returns (Domain) {} - rpc ListDomains(ListDomainsRequest) returns (ListDomainsResponse) {} - rpc CreateDomain(CreateDomainRequest) returns (Domain) {} - rpc DeleteDomain(DeleteDomainRequest) returns (google.protobuf.Empty) {} - - rpc DownloadImage(DownloadImageRequest) returns (stream ImageChunk) {} - - rpc GetVolume(GetVolumeRequest) returns (Volume) {} - rpc ListVolumes(ListVolumesRequest) returns (ListVolumesResponse) {} - rpc CreateVolume(CreateVolumeRequest) returns (Volume) {} - rpc UpdateVolume(UpdateVolumeRequest) returns (Volume) {} - rpc DeleteVolume(DeleteVolumeRequest) returns (google.protobuf.Empty) {} - - rpc ListVolumeAttachments(ListVolumeAttachmentsRequest) returns (ListVolumeAttachmentsResponse) {} - rpc GetVolumeAttachment(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc AttachVolume(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc DetachVolume(VolumeAttachmentIdentifier) returns (google.protobuf.Empty) {} - - rpc GetPortForwarding(PortForwardingIdentifier) returns (PortForwarding) {} - rpc ListPortForwardings(ListPortForwardingsRequest) returns (ListPortForwardingsResponse) {} - rpc PutPortForwarding(PutPortForwardingRequest) returns (PortForwarding) {} - rpc DeletePortForwarding(PortForwardingIdentifier) returns (google.protobuf.Empty) {} - - rpc SyncRoutes(SyncRoutesRequest) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/dns.proto b/protos/minivirt/dns.proto deleted file mode 100644 index 53b6d5a..0000000 --- a/protos/minivirt/dns.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; - -message DNSRecordIdentifier { - string name = 1; - string type = 2; -} - -message DNSRecord { - string name = 1; - string type = 2; - uint64 ttl = 3; - repeated string records = 4; -} - -message ListDNSRecordsRequest {} - -message ListDNSRecordsResponse { - repeated DNSRecord dns_records = 1; -} - -message PutDNSRecordRequest { - DNSRecord dns_record = 1; -} - -service DNS { - rpc GetDNSRecord(DNSRecordIdentifier) returns (DNSRecord) {} - rpc ListDNSRecords(ListDNSRecordsRequest) returns (ListDNSRecordsResponse) {} - rpc PutDNSRecord(PutDNSRecordRequest) returns (DNSRecord) {} - rpc DeleteDNSRecord(DNSRecordIdentifier) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/domain.proto b/protos/minivirt/domain.proto deleted file mode 100644 index aa7e76b..0000000 --- a/protos/minivirt/domain.proto +++ /dev/null @@ -1,113 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -message StartDomainRequest { - string host = 1; - string uuid = 2; -} - -message StopDomainRequest { - string host = 1; - string uuid = 2; - bool force = 3; -} - -message GetDomainRequest { - string uuid = 1; - string host = 2; -} - -message Domain { - uint64 id = 1; - string uuid = 2; - string name = 3; - uint32 vcpu = 4; - uint64 memory = 5; - string network = 6; - string bridge = 7; - string state = 8; - string private_ip = 9; - string ipv6_address = 15; - string user_data = 10; - bool nested_virtualization = 11; - string base_image = 12; - google.protobuf.Timestamp created_at = 13; - string os_type = 14; -} - -message ListDomainsRequest { - string host = 1; -} - -message ListDomainsResponse { - repeated Domain domains = 1; -} - -message CreateDomainRequest { - Domain domain = 1; - string host = 2; -} - -message DeleteDomainRequest { - string uuid = 1; - string host = 2; -} - -message DownloadImageRequest { - string domain_id = 1; - string host = 2; -} - -message ImageChunk { - bytes bytes = 1; -} - - -message GetNetworkRequest { - string uuid = 1; - string host = 2; -} - -message Network { - string uuid = 1; - string name = 2; - string cidr = 3; - string cidr6 = 4; -} - -message ListNetworksRequest { - string host = 1; -} - -message ListNetworksResponse { - repeated Network networks = 1; -} - -message CreateNetworkRequest { - Network network = 1; - string host = 2; -} - -message DeleteNetworkRequest { - string uuid = 1; - string host = 2; -} - - -service DomainService { - rpc GetDomain(GetDomainRequest) returns (Domain) {} - rpc ListDomains(ListDomainsRequest) returns (ListDomainsResponse) {} - rpc CreateDomain(CreateDomainRequest) returns (Domain) {} - rpc DeleteDomain(DeleteDomainRequest) returns (google.protobuf.Empty) {} - - rpc DownloadImage(DownloadImageRequest) returns (stream ImageChunk) {} - - rpc GetNetwork(GetNetworkRequest) returns (Network) {} - rpc ListNetworks(ListNetworksRequest) returns (ListNetworksResponse) {} - rpc CreateNetwork(CreateNetworkRequest) returns (Network) {} - rpc DeleteNetwork(DeleteNetworkRequest) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/host.proto b/protos/minivirt/host.proto deleted file mode 100644 index c3ab844..0000000 --- a/protos/minivirt/host.proto +++ /dev/null @@ -1,46 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; - -message CreateBootstrapTokenRequest { - string expires_at = 1; -} - -message CreateBootstrapTokenResponse { - string token = 1; -} - -message Host { - string name = 1; - string address = 2; -} - -message ListHostsRequest {} - -message ListHostsResponse { - repeated Host hosts = 1; -} - -message RegisterHostRequest { - Host host = 1; - string token = 2; -} - -message HeartbeatRequest { - Host host = 1; -} - -message HeartbeatResponse { -} - -service HostService { - rpc CreateBootstrapToken(CreateBootstrapTokenRequest) returns (CreateBootstrapTokenResponse) {} - rpc GetHost(Host) returns (Host) {} - rpc ListHosts(ListHostsRequest) returns (ListHostsResponse) {} - rpc Register(RegisterHostRequest) returns (Host) {} - rpc Deregister(Host) returns (google.protobuf.Empty) {} - - rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse) {} -} diff --git a/protos/minivirt/port_forwarding.proto b/protos/minivirt/port_forwarding.proto deleted file mode 100644 index 1151264..0000000 --- a/protos/minivirt/port_forwarding.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; - -message PortForwardingIdentifier { - string host = 1; - string protocol = 2; - uint32 source_port = 3; -} - -message PortForwarding { - string protocol = 2; - uint32 source_port = 3; - string target_ip = 4; - uint32 target_port = 5; -} - -message ListPortForwardingsRequest { - string host = 1; -} - -message ListPortForwardingsResponse { - repeated PortForwarding port_forwardings = 1; -} - -message PutPortForwardingRequest { - PortForwarding port_forwarding = 1; - string host = 2; -} - -service PortForwardingService { - rpc GetPortForwarding(PortForwardingIdentifier) returns (PortForwarding) {} - rpc ListPortForwardings(ListPortForwardingsRequest) returns (ListPortForwardingsResponse) {} - rpc PutPortForwarding(PutPortForwardingRequest) returns (PortForwarding) {} - rpc DeletePortForwarding(PortForwardingIdentifier) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/route.proto b/protos/minivirt/route.proto deleted file mode 100644 index a375d89..0000000 --- a/protos/minivirt/route.proto +++ /dev/null @@ -1,67 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; - -message RouteTable { - string network_name = 1; - uint32 id = 2; - string name = 3; -} - -message RouteTableIdentifier { - uint32 id = 1; -} - -message ListRouteTablesRequest { - string network_name = 1; -} - -message ListRouteTablesResponse { - repeated RouteTable route_tables = 1; -} - -message CreateRouteTableRequest { - RouteTable route_table = 1; -} - -message RouteIdentifier { - uint32 route_table_id = 1; - string destination = 2; -} - -message Route { - uint32 route_table_id = 1; - string destination = 2; - repeated string gateways = 3; -} - -message ListRoutesRequest { - uint32 route_table_id = 1; -} - -message ListRoutesResponse { - repeated Route routes = 1; -} - -message PutRouteRequest { - Route route = 1; -} - -message SyncRequest { -} - -service RouteService { - rpc GetRouteTable(RouteTableIdentifier) returns (RouteTable) {} - rpc ListRouteTables(ListRouteTablesRequest) returns (ListRouteTablesResponse) {} - rpc CreateRouteTable(CreateRouteTableRequest) returns (RouteTable) {} - rpc DeleteRouteTable(RouteTableIdentifier) returns (google.protobuf.Empty) {} - - rpc GetRoute(RouteIdentifier) returns (Route) {} - rpc ListRoutes(ListRoutesRequest) returns (ListRoutesResponse) {} - rpc PutRoute(PutRouteRequest) returns (Route) {} - rpc DeleteRoute(RouteIdentifier) returns (google.protobuf.Empty) {} - - rpc Sync(SyncRequest) returns (google.protobuf.Empty) {} -} diff --git a/protos/minivirt/volume.proto b/protos/minivirt/volume.proto deleted file mode 100644 index ec1cd07..0000000 --- a/protos/minivirt/volume.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;pb"; - -import "google/protobuf/empty.proto"; - -message GetVolumeRequest { - string uuid = 1; - string host = 2; -} - -message Volume { - string id = 1; - string name = 2; - uint64 size = 3; -} - -message ListVolumesRequest { - string host = 1; -} - -message ListVolumesResponse { - repeated Volume volumes = 1; -} - -message CreateVolumeRequest { - Volume volume = 1; - string host = 2; -} - -message UpdateVolumeRequest { - string host = 1; - Volume volume = 2; -} - -message DeleteVolumeRequest { - string uuid = 1; - string host = 2; -} - -message VolumeAttachmentIdentifier { - string domain_id = 1; - string volume_id = 2; - string host = 3; -} - -message VolumeAttachment { - string domain_id = 1; - string volume_id = 2; - string disk_address = 3; -} - -message ListVolumeAttachmentsRequest { - string domain_id = 1; - string host = 2; -} - -message ListVolumeAttachmentsResponse { - repeated VolumeAttachment attachments = 1; -} - -service VolumeService { - rpc GetVolume(GetVolumeRequest) returns (Volume) {} - rpc ListVolumes(ListVolumesRequest) returns (ListVolumesResponse) {} - rpc CreateVolume(CreateVolumeRequest) returns (Volume) {} - rpc UpdateVolume(UpdateVolumeRequest) returns (Volume) {} - rpc DeleteVolume(DeleteVolumeRequest) returns (google.protobuf.Empty) {} - - rpc ListVolumeAttachments(ListVolumeAttachmentsRequest) returns (ListVolumeAttachmentsResponse) {} - rpc GetVolumeAttachment(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc AttachVolume(VolumeAttachmentIdentifier) returns (VolumeAttachment) {} - rpc DetachVolume(VolumeAttachmentIdentifier) returns (google.protobuf.Empty) {} -} diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 2a9d90d..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,18 +0,0 @@ -#[project.scripts] -#restvirt="main:main" - -[tool.black] -line-length = 100 -exclude = ''' -( - migrations/ - | venv/ - | .*_pb2(_grpc)?.py -) -''' - -[tool.isort] -profile="black" -combine_as_imports="true" -skip_glob=["*_pb2.py","*_pb2_grpc.py"] -line_length=100 diff --git a/virtuerl/rebar.config b/rebar.config similarity index 100% rename from virtuerl/rebar.config rename to rebar.config diff --git a/virtuerl/rebar.lock b/rebar.lock similarity index 100% rename from virtuerl/rebar.lock rename to rebar.lock diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 6820cd1..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ -pytest==7.2.0 -isort[colors]==5.10.1 -black==22.6.0 -fabric==2.7.1 -grpcio-tools==1.51.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 35bb0d5..0000000 --- a/requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -libvirt-python==8.10.0 -grpcio==1.51.1 -grpcio-reflection==1.51.1 -protobuf==4.21.10 -pycdlib==1.12.0 -pyroute2==0.7.2 -git+https://salsa.debian.org/pkg-netfilter-team/pkg-nftables.git@upstream/1.0.4#egg=nftables&subdirectory=py -python-iptables==1.0.0 -SQLAlchemy==1.4.44 -xmltodict==0.12.0 -dnslib==0.9.16 -dnspython==2.2.1 -PyYAML==6.0 -requests==2.31.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 551e719..0000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -from setuptools import find_packages, setup - -from minivirt.version import __version__ - -setup( - name="restvirt", - version="0.1", # TODO: use __version__ instead - packages=find_packages(), - url="", - license="Apache", - author="Ilya Verbitskiy", - author_email="ilya@verbit.io", - description="", - entry_points={"console_scripts": ["restvirt=minivirt.main:main"]}, - install_requires=[ - "libvirt-python==8.10.0", - "grpcio==1.51.1", - "grpcio-reflection==1.51.1", - "protobuf==4.21.10", - "pycdlib==1.12.0", - "pyroute2==0.7.2", - "nftables @ git+https://salsa.debian.org/pkg-netfilter-team/pkg-nftables.git@upstream/1.0.4#egg=nftables&subdirectory=py", - "python-iptables==1.0.0", - "SQLAlchemy==1.4.44", - "xmltodict==0.12.0", - "dnslib==0.9.16", - "dnspython==2.2.1", - "PyYAML==6.0", - "requests==2.31.0", - ], -) diff --git a/snap/hooks/configure b/snap/hooks/configure deleted file mode 100755 index 4622a34..0000000 --- a/snap/hooks/configure +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -e - -mkdir -p "$SNAP_DATA/var/run/bird/" -if [ ! -f "$SNAP_DATA/etc/bird/minivirt.conf" ]; then - mkdir -p "$SNAP_DATA/etc/bird/" - cp "$SNAP/etc/bird/minivirt.conf" "$SNAP_DATA/etc/bird/minivirt.conf" -fi - -controller_args="$(snapctl get controller.args)" -if [ -z "$controller_args" ]; then - snapctl set controller.args='-c $SNAP_COMMON' -fi - -daemon_args="$(snapctl get daemon.args)" -if [ -z "$daemon_args" ]; then - snapctl set daemon.args='-c $SNAP_COMMON' -fi - -snapctl restart minivirt diff --git a/snap/hooks/install b/snap/hooks/install deleted file mode 100644 index 2140bca..0000000 --- a/snap/hooks/install +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -snapctl stop --disable minivirt diff --git a/snap/local/bin/bird-wrapper b/snap/local/bin/bird-wrapper deleted file mode 100755 index e113aaa..0000000 --- a/snap/local/bin/bird-wrapper +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec bird -f -c "$SNAP_DATA/etc/bird/minivirt.conf" -s "$SNAP_DATA/var/run/bird/bird.ctl" diff --git a/snap/local/bin/birdc-wrapper b/snap/local/bin/birdc-wrapper deleted file mode 100755 index 2dc229f..0000000 --- a/snap/local/bin/birdc-wrapper +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec birdc -s "$SNAP_DATA/var/run/bird/bird.ctl" "$@" diff --git a/snap/local/bin/restvirt-controller b/snap/local/bin/restvirt-controller deleted file mode 100755 index 50ed1e7..0000000 --- a/snap/local/bin/restvirt-controller +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec restvirt controller $(snapctl get controller.args | envsubst) diff --git a/snap/local/bin/restvirt-daemon b/snap/local/bin/restvirt-daemon deleted file mode 100755 index 533826b..0000000 --- a/snap/local/bin/restvirt-daemon +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec restvirt daemon $(snapctl get daemon.args | envsubst) diff --git a/snap/local/bin/restvirt-deregister b/snap/local/bin/restvirt-deregister deleted file mode 100755 index 92cc0de..0000000 --- a/snap/local/bin/restvirt-deregister +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec restvirt deregister "$@" diff --git a/snap/local/bin/restvirt-register b/snap/local/bin/restvirt-register deleted file mode 100755 index ed0eaa7..0000000 --- a/snap/local/bin/restvirt-register +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec restvirt register "$@" diff --git a/snap/local/bin/unbound-wrapper b/snap/local/bin/unbound-wrapper deleted file mode 100755 index 5c544be..0000000 --- a/snap/local/bin/unbound-wrapper +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec unbound -d -p -c "$SNAP/etc/unbound/minivirt.conf" diff --git a/snap/local/etc/bird/minivirt.conf b/snap/local/etc/bird/minivirt.conf deleted file mode 100644 index 255aaa0..0000000 --- a/snap/local/etc/bird/minivirt.conf +++ /dev/null @@ -1,229 +0,0 @@ -# This is a basic configuration file, which contains boilerplate options and -# some basic examples. It allows the BIRD daemon to start but will not cause -# anything else to happen. -# -# Please refer to the BIRD User's Guide documentation, which is also available -# online at http://bird.network.cz/ in HTML format, for more information on -# configuring BIRD and adding routing protocols. - -# Configure logging -log syslog all; -# log "/var/log/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug }; - -# Set router ID. It is a unique identification of your router, usually one of -# IPv4 addresses of the router. It is recommended to configure it explicitly. -# router id 198.51.100.1; - -# Turn on global debugging of all protocols (all messages or just selected classes) -# debug protocols all; -# debug protocols { events, states }; - -# Turn on internal watchdog -# watchdog warning 5 s; -# watchdog timeout 30 s; - -# You can define your own constants -# define my_asn = 65000; -# define my_addr = 198.51.100.1; - -# Tables master4 and master6 are defined by default -# ipv4 table master4; -# ipv6 table master6; - -# Define more tables, e.g. for policy routing or as MRIB -# ipv4 table mrib4; -# ipv6 table mrib6; - -# The Device protocol is not a real routing protocol. It does not generate any -# routes and it only serves as a module for getting information about network -# interfaces from the kernel. It is necessary in almost any configuration. -protocol device { -} - -# The direct protocol is not a real routing protocol. It automatically generates -# direct routes to all network interfaces. Can exist in as many instances as you -# wish if you want to populate multiple routing tables with direct routes. -protocol direct { - disabled; # Disable by default - ipv4; # Connect to default IPv4 table - ipv6; # ... and to default IPv6 table -} - -# The Kernel protocol is not a real routing protocol. Instead of communicating -# with other routers in the network, it performs synchronization of BIRD -# routing tables with the OS kernel. One instance per table. -protocol kernel { - merge paths on; - ipv4 { # Connect protocol to IPv4 table by channel -# table master4; # Default IPv4 table is master4 - import all; # Import to table, default is import all - export all; # Export to protocol. default is export none - }; -# learn; # Learn alien routes from the kernel -# kernel table 30068; # Kernel table to synchronize with (default: main) -} - -# Another instance for IPv6, skipping default options -protocol kernel { - ipv6 { export all; }; -} - -# Static routes (Again, there can be multiple instances, for different address -# families and to disable/enable various groups of static routes on the fly). -protocol static { - ipv4; # Again, IPv4 channel with default options - -# route 0.0.0.0/0 via 198.51.100.10; -# route 192.0.2.0/24 blackhole; -# route 10.0.0.0/8 unreachable; -# route 10.2.0.0/24 via "eth0"; -# # Static routes can be defined with optional attributes -# route 10.1.1.0/24 via 198.51.100.3 { rip_metric = 3; }; -# route 10.1.2.0/24 via 198.51.100.3 { ospf_metric1 = 100; }; -# route 10.1.3.0/24 via 198.51.100.4 { ospf_metric2 = 100; }; -} - -# Pipe protocol connects two routing tables. Beware of loops. -# protocol pipe { -# table master4; # No ipv4/ipv6 channel definition like in other protocols -# peer table mrib4; -# import all; # Direction peer table -> table -# export all; # Direction table -> peer table -# } - -# RIP example, both RIP and RIPng are supported -# protocol rip { -# ipv4 { -# # Export direct, static routes and ones from RIP itself -# import all; -# export where source ~ [ RTS_DEVICE, RTS_STATIC, RTS_RIP ]; -# }; -# interface "eth*" { -# update time 10; # Default period is 30 -# timeout time 60; # Default timeout is 180 -# authentication cryptographic; # No authentication by default -# password "hello" { algorithm hmac sha256; }; # Default is MD5 -# }; -# } - -# OSPF example, both OSPFv2 and OSPFv3 are supported -# protocol ospf v3 { -# ipv6 { -# import all; -# export where source = RTS_STATIC; -# }; -# area 0 { -# interface "eth*" { -# type broadcast; # Detected by default -# cost 10; # Interface metric -# hello 5; # Default hello perid 10 is too long -# }; -# interface "tun*" { -# type ptp; # PtP mode, avoids DR selection -# cost 100; # Interface metric -# hello 5; # Default hello perid 10 is too long -# }; -# interface "dummy0" { -# stub; # Stub interface, just propagate it -# }; -# }; -#} - -# Define simple filter as an example for BGP import filter -# See https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering for more examples -# filter rt_import -# { -# if bgp_path.first != 64496 then accept; -# if bgp_path.len > 64 then accept; -# if bgp_next_hop != from then accept; -# reject; -# } - -protocol bgp k8s { - local as 64513; - neighbor range 192.168.122.0/24 port 179 as 64513; - direct; - rr client; - passive on; - ipv4 { - add paths on; - import all; - export all; - }; -} - -# protocol bgp up { -# local port 178 as 64513; -# neighbor 192.168.122.111 as 64513; -# direct; -# ipv4 { -# add paths on; -# import all; -# export none; -# }; -# } - -# BGP example, explicit name 'uplink1' is used instead of default 'bgp1' -# protocol bgp uplink1 { -# description "My BGP uplink"; -# local 198.51.100.1 as 65000; -# neighbor 198.51.100.10 as 64496; -# hold time 90; # Default is 240 -# password "secret"; # Password used for MD5 authentication -# -# ipv4 { # regular IPv4 unicast (1/1) -# import filter rt_import; -# export where source ~ [ RTS_STATIC, RTS_BGP ]; -# }; -# -# ipv6 { # regular IPv6 unicast (2/1) -# import filter rt_import; -# export filter { # The same as 'where' expression above -# if source ~ [ RTS_STATIC, RTS_BGP ] -# then accept; -# else reject; -# }; -# }; -# -# ipv4 multicast { # IPv4 multicast topology (1/2) -# table mrib4; # explicit IPv4 table -# import filter rt_import; -# export all; -# }; -# -# ipv6 multicast { # IPv6 multicast topology (2/2) -# table mrib6; # explicit IPv6 table -# import filter rt_import; -# export all; -# }; -#} - -# Template example. Using templates to define IBGP route reflector clients. -# template bgp rr_clients { -# local 10.0.0.1 as 65000; -# neighbor as 65000; -# rr client; -# rr cluster id 1.0.0.1; -# -# ipv4 { -# import all; -# export where source = RTS_BGP; -# }; -# -# ipv6 { -# import all; -# export where source = RTS_BGP; -# }; -# } -# -# protocol bgp client1 from rr_clients { -# neighbor 10.0.1.1; -# } -# -# protocol bgp client2 from rr_clients { -# neighbor 10.0.2.1; -# } -# -# protocol bgp client3 from rr_clients { -# neighbor 10.0.3.1; -# } diff --git a/snap/local/etc/unbound/minivirt.conf b/snap/local/etc/unbound/minivirt.conf deleted file mode 100644 index 383e96a..0000000 --- a/snap/local/etc/unbound/minivirt.conf +++ /dev/null @@ -1,20 +0,0 @@ -server: - #logfile: "/var/log/unbound/unbound.log" - verbosity: 1 - chroot: "" - username: "" - port: 5354 - interface: 0.0.0.0 - interface: ::0 - access-control: 192.168.0.0/16 allow - access-control: 10.0.0.0/8 allow - access-control: fc00::/7 allow - do-ip6: yes - do-not-query-localhost: no - domain-insecure: "internal" - directory: "." -remote-control: - control-enable: no -stub-zone: - name: "internal" - stub-addr: 127.0.0.1@5353 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml deleted file mode 100644 index 8553d93..0000000 --- a/snap/snapcraft.yaml +++ /dev/null @@ -1,83 +0,0 @@ -name: minivirt # you probably want to 'snapcraft register ' -base: core22 # the base snap is the execution environment for this snap -version: 'git' # just for humans, typically '1.2+git' or '1.3.2' -summary: Single-line elevator pitch for your amazing snap # 79 char long summary -description: | - This is my-snap's description. You have a paragraph or two to tell the - most important story about your snap. Keep it under 100 words though, - we live in tweetspace and your description wants to look good in the snap - store. - -grade: stable # must be 'stable' to release into candidate/stable channels -confinement: strict # use 'strict' once you have the right plugs and slots - -apps: - controller: - command: bin/restvirt-controller - daemon: simple - plugs: - - network - - network-bind - unbound: - command: bin/unbound-wrapper - daemon: simple - after: - - controller - plugs: - - network - - network-bind - bird: - command: bin/bird-wrapper - daemon: simple - before: - - daemon - plugs: - - network - - network-bind - - network-control - birdc: - command: bin/birdc-wrapper - register: - command: bin/restvirt-register - plugs: - - network - - network-bind - deregister: - command: bin/restvirt-deregister - plugs: - - network - - network-bind - daemon: - command: bin/restvirt-daemon - daemon: simple - after: - - controller - restart-condition: always - restart-delay: 2s - plugs: - - libvirt - - network - - network-bind - - network-control - - firewall-control - -parts: - wrapper: - plugin: dump - source: snap/local/ - stage-packages: - - gettext-base - minivirt: - # See 'snapcraft plugins' - plugin: python - source: ./ - build-packages: - - git - - libvirt-dev - - pkg-config - stage-packages: - - libvirt0 - - libbrotli1 # kill me please - - libnftables1 - - unbound - - bird2 diff --git a/virtuerl/src/virtuerl.app.src b/src/virtuerl.app.src similarity index 100% rename from virtuerl/src/virtuerl.app.src rename to src/virtuerl.app.src diff --git a/virtuerl/src/virtuerl_api.erl b/src/virtuerl_api.erl similarity index 100% rename from virtuerl/src/virtuerl_api.erl rename to src/virtuerl_api.erl diff --git a/virtuerl/src/virtuerl_app.erl b/src/virtuerl_app.erl similarity index 100% rename from virtuerl/src/virtuerl_app.erl rename to src/virtuerl_app.erl diff --git a/virtuerl/src/virtuerl_ghac.erl b/src/virtuerl_ghac.erl similarity index 100% rename from virtuerl/src/virtuerl_ghac.erl rename to src/virtuerl_ghac.erl diff --git a/virtuerl/src/virtuerl_img.erl b/src/virtuerl_img.erl similarity index 100% rename from virtuerl/src/virtuerl_img.erl rename to src/virtuerl_img.erl diff --git a/virtuerl/src/virtuerl_ipam.erl b/src/virtuerl_ipam.erl similarity index 100% rename from virtuerl/src/virtuerl_ipam.erl rename to src/virtuerl_ipam.erl diff --git a/virtuerl/src/virtuerl_mgt.erl b/src/virtuerl_mgt.erl similarity index 100% rename from virtuerl/src/virtuerl_mgt.erl rename to src/virtuerl_mgt.erl diff --git a/virtuerl/src/virtuerl_net.erl b/src/virtuerl_net.erl similarity index 100% rename from virtuerl/src/virtuerl_net.erl rename to src/virtuerl_net.erl diff --git a/virtuerl/src/virtuerl_pubsub.erl b/src/virtuerl_pubsub.erl similarity index 100% rename from virtuerl/src/virtuerl_pubsub.erl rename to src/virtuerl_pubsub.erl diff --git a/virtuerl/src/virtuerl_qemu.erl b/src/virtuerl_qemu.erl similarity index 100% rename from virtuerl/src/virtuerl_qemu.erl rename to src/virtuerl_qemu.erl diff --git a/virtuerl/src/virtuerl_qmp.erl b/src/virtuerl_qmp.erl similarity index 100% rename from virtuerl/src/virtuerl_qmp.erl rename to src/virtuerl_qmp.erl diff --git a/virtuerl/src/virtuerl_sup.erl b/src/virtuerl_sup.erl similarity index 100% rename from virtuerl/src/virtuerl_sup.erl rename to src/virtuerl_sup.erl diff --git a/virtuerl/src/virtuerl_ui.erl b/src/virtuerl_ui.erl similarity index 100% rename from virtuerl/src/virtuerl_ui.erl rename to src/virtuerl_ui.erl diff --git a/virtuerl/src/virtuerl_util.erl b/src/virtuerl_util.erl similarity index 100% rename from virtuerl/src/virtuerl_util.erl rename to src/virtuerl_util.erl diff --git a/virtuerl/src/virtuerl_vnc.erl b/src/virtuerl_vnc.erl similarity index 100% rename from virtuerl/src/virtuerl_vnc.erl rename to src/virtuerl_vnc.erl diff --git a/virtuerl/src/virtuerl_vnc_proxy.erl b/src/virtuerl_vnc_proxy.erl similarity index 100% rename from virtuerl/src/virtuerl_vnc_proxy.erl rename to src/virtuerl_vnc_proxy.erl diff --git a/virtuerl/test/ipam.erl b/test/ipam.erl similarity index 100% rename from virtuerl/test/ipam.erl rename to test/ipam.erl diff --git a/virtuerl/test/scheduler.erl b/test/scheduler.erl similarity index 100% rename from virtuerl/test/scheduler.erl rename to test/scheduler.erl diff --git a/virtuerl/test/virtuerl_SUITE.erl b/test/virtuerl_SUITE.erl similarity index 100% rename from virtuerl/test/virtuerl_SUITE.erl rename to test/virtuerl_SUITE.erl diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py deleted file mode 100644 index fa437d2..0000000 --- a/tests/integration/test_integration.py +++ /dev/null @@ -1,211 +0,0 @@ -import datetime -import io -from time import sleep -from urllib.parse import urljoin -from urllib.request import urlopen - -import grpc -import pytest -from fabric import Connection -from paramiko.ed25519key import Ed25519Key - -from minivirt import controller_pb2_grpc, domain_pb2, port_forwarding_pb2, volume_pb2 - - -@pytest.fixture -def client(): - channel = grpc.secure_channel( - "localhost:8093", - grpc.ssl_channel_credentials( - root_certificates=b"""-----BEGIN CERTIFICATE----- -MIICCjCCAY+gAwIBAgIUSl7KWjtgvG9rNMz7hhYRKy5LsB8wCgYIKoZIzj0EAwIw -RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp -cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMjUyMFoXDTMzMDcwNTIz -MjUyMFowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI -bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID -YgAEI3nOFzsWO3w8qGLSjDSiX3OWCH7qBRcTjt/luPjXLqe3DVcFQPLYN31PaggR -o0jCjrKklxqtzHmmMdMRnyoRPbQOQPRa9N177a2s97M5ZJQVkeFL8WRUf7x1P0Cd -SZvco0IwQDAdBgNVHQ4EFgQUde9ormRTZys4Nt81qAPcSm1qQWMwDwYDVR0TAQH/ -BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwIDaQAwZgIxAJTpUOUz -RJwMLNUEa4qIgdamMuqyl5h6ghT9zX5BLsX3cFs+MqJ/J0HcKDJd81lVlQIxAPCG -hy/zgj6wy28S8GWe8KdbZ73BJtC5MyOu6hHD9EpZ1hT8K3q0VIwMEyUMmbv3Xw== ------END CERTIFICATE----- -""", - certificate_chain=b"""-----BEGIN CERTIFICATE----- -MIICeTCCAf+gAwIBAgIUVG1gWhFwRQ5kzxwRzF6V5h6D8ZYwCgYIKoZIzj0EAwIw -RDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwIbWluaXZp -cnQxETAPBgNVBAMMCG1pbml2aXJ0MB4XDTIzMDcwODIzMzA0MloXDTI1MDcwNzIz -MzA0MlowRDELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjERMA8GA1UECgwI -bWluaXZpcnQxETAPBgNVBAMMCG1pbml2aXJ0MHYwEAYHKoZIzj0CAQYFK4EEACID -YgAEHWV9eL3/egpqcgTaMDPWga2xpfTZCc66yNxkVGPsw5BWE/EXvWtuUCjDmHWo -HOdrbt7iI9lA9VnSwlC9PeIvX4lK2dXNOpn3GJlZ8JkjpZZBg0mxaUt6vQMyGSco -cOOAo4GxMIGuMB8GA1UdIwQYMBaAFHXvaK5kU2crODbfNagD3EptakFjMAwGA1Ud -EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMB -BggrBgEFBQcDAjAsBgNVHREEJTAjgglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAA -AAAAAAAAAAEwHQYDVR0OBBYEFDtlzMapZ4eV0/m8ina1GM3biELeMAoGCCqGSM49 -BAMCA2gAMGUCMECXLmHsWMTaFRK+qWaBRZMLuhFNixMsSmmHHIqGlvIrWFa5MiN6 -RaZ7aTGa/HMKZAIxAPRJZ11Vp1BNBszSiswk32hsck4JP9h1hn00IMu33iK0+q22 -Jv73oZy3l4gQmLlCDg== ------END CERTIFICATE----- -""", - private_key=b"""-----BEGIN PRIVATE KEY----- -MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDCIJQuTNENeEnhjCtdV -GXoFgh69LQ+Ms5B/i0jWMSqMALL26uG6NNM4nvHgIMbChKGhZANiAAQdZX14vf96 -CmpyBNowM9aBrbGl9NkJzrrI3GRUY+zDkFYT8Re9a25QKMOYdagc52tu3uIj2UD1 -WdLCUL094i9fiUrZ1c06mfcYmVnwmSOllkGDSbFpS3q9AzIZJyhw44A= ------END PRIVATE KEY----- -""", - ), - ) - return controller_pb2_grpc.ControllerServiceStub(channel) - - -def test_create_domain_ipv4_linux(client: controller_pb2_grpc.ControllerServiceStub): - network = client.CreateNetwork( - domain_pb2.CreateNetworkRequest( - network=domain_pb2.Network( - name="restvirt", - cidr="192.168.69.0/24", - ) - ) - ) - dom = client.CreateDomain( - domain_pb2.CreateDomainRequest( - domain=domain_pb2.Domain( - name="test", - vcpu=1, - memory=512, - private_ip="192.168.69.69", - network=network.uuid, - user_data="""#cloud-config""", - ), - ) - ) - dom = client.GetDomain(domain_pb2.GetDomainRequest(uuid=dom.uuid)) - assert dom.private_ip == "192.168.69.69" - - client.DeleteDomain(domain_pb2.DeleteDomainRequest(uuid=dom.uuid)) - client.DeleteNetwork(domain_pb2.DeleteNetworkRequest(uuid=network.uuid)) - - -def test_create_domain_linux(client: controller_pb2_grpc.ControllerServiceStub): - network = client.CreateNetwork( - domain_pb2.CreateNetworkRequest( - network=domain_pb2.Network( - name="restvirt", - cidr="192.168.69.0/24", - cidr6="fd8d:dd47:05bc:5307::/64", - ) - ) - ) - dom = client.CreateDomain( - domain_pb2.CreateDomainRequest( - domain=domain_pb2.Domain( - name="test", - vcpu=1, - memory=512, - private_ip="192.168.69.69", - ipv6_address="fd8d:dd47:05bc:5307::10", - network=network.uuid, - user_data="""#cloud-config - -users: - - name: tester - shell: /bin/bash - sudo: ALL=(ALL) NOPASSWD:ALL - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBDCT3LrJenezXzP9T6519IgpVCP1uv6f5iQwZ+IDdFc - -packages: - - nginx - -runcmd: - - service nginx restart -""", - ), - ) - ) - - dom = client.GetDomain(domain_pb2.GetDomainRequest(uuid=dom.uuid)) - assert dom.ipv6_address == "fd8d:dd47:05bc:5307::10" - - fwd = port_forwarding_pb2.PortForwarding( - protocol="tcp", - source_port=8080, - target_ip="192.168.69.69", - target_port=80, - ) - client.PutPortForwarding(port_forwarding_pb2.PutPortForwardingRequest(port_forwarding=fwd)) - - response = wait_for_http("http://192.168.69.1:8080") - assert "Welcome to nginx!" in response - - private_ssh_key = """-----BEGIN OPENSSH PRIVATE KEY----- -b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW -QyNTUxOQAAACAQwk9y6yXp3s18z/U+udfSIKVQj9br+n+YkMGfiA3RXAAAAJhEeSndRHkp -3QAAAAtzc2gtZWQyNTUxOQAAACAQwk9y6yXp3s18z/U+udfSIKVQj9br+n+YkMGfiA3RXA -AAAEC9jx0pxfKwyPq3RpOsCef7UA2pqBzAj2+bqVTix2f0fRDCT3LrJenezXzP9T6519Ig -pVCP1uv6f5iQwZ+IDdFcAAAAFWlseWFASWx5YXMtaU1hYy5sb2NhbA== ------END OPENSSH PRIVATE KEY----- -""" - with io.StringIO(private_ssh_key) as f: - pkey = Ed25519Key.from_private_key(f) - conn = Connection("192.168.69.69", "tester", connect_kwargs={"pkey": pkey}) - conn.config.run.in_stream = False - - old_root_vol_size = int(conn.run("lsblk /dev/vda -bndo SIZE").stdout) - assert old_root_vol_size == 20 * 1024**3 - - volumes = client.ListVolumes(volume_pb2.ListVolumesRequest()) - volumes = {v.name: v for v in volumes.volumes} - root_vol_name = f"{dom.name}-root.qcow2" - assert root_vol_name in volumes - - wait_until_stopped(client, dom.uuid) - client.UpdateVolume( - volume_pb2.UpdateVolumeRequest( - volume=volume_pb2.Volume(id=root_vol_name, size=30 * 1024**3) - ) - ) - - client.StartDomain(domain_pb2.StartDomainRequest(uuid=dom.uuid)) - response = wait_for_http("http://192.168.69.1:8080") - assert "Welcome to nginx!" in response - response = wait_for_http("http://[fd8d:dd47:05bc:5307::10]") - assert "Welcome to nginx!" in response - - new_root_vol_size = int(conn.run("lsblk /dev/vda -bndo SIZE").stdout) - assert new_root_vol_size == 30 * 1024**3 - - client.DeletePortForwarding( - port_forwarding_pb2.PortForwardingIdentifier(protocol="tcp", source_port=8080) - ) - client.DeleteDomain(domain_pb2.DeleteDomainRequest(uuid=dom.uuid)) - client.DeleteNetwork(domain_pb2.DeleteNetworkRequest(uuid=network.uuid)) - - -def wait_for_http(server, path="/", timeout=datetime.timedelta(seconds=180)): - end_time = datetime.datetime.now() + timeout - while True: - try: - with urlopen(urljoin(server, path)) as resp: - return resp.read().decode() - except: - now = datetime.datetime.now() - if now >= end_time: - raise Exception("Timed out") - sleep(min((end_time - now).total_seconds(), 10)) - - -def wait_until_stopped(client, domain_uuid, timeout=datetime.timedelta(seconds=180)): - end_time = datetime.datetime.now() + timeout - while True: - dom = client.GetDomain(domain_pb2.GetDomainRequest(uuid=domain_uuid)) - if dom.state == "SHUTOFF": - break - - client.StopDomain(domain_pb2.StopDomainRequest(uuid=domain_uuid)) - now = datetime.datetime.now() - if now >= end_time: - raise Exception("Timed out") - sleep(min((end_time - now).total_seconds(), 10)) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py deleted file mode 100644 index bce86d3..0000000 --- a/tests/unit/conftest.py +++ /dev/null @@ -1,231 +0,0 @@ -import contextlib -import sys -from concurrent import futures - -import grpc -import pytest -from google.protobuf import empty_pb2 -from sqlalchemy import create_engine, event -from sqlalchemy.engine import Engine -from sqlalchemy.orm import sessionmaker -from sqlalchemy.pool import StaticPool - -from minivirt import controller_pb2_grpc, daemon_pb2_grpc, host_pb2, host_pb2_grpc -from minivirt.controller import Controller -from minivirt.dns_controller import DNSController -from minivirt.host import HostController, HostService -from minivirt.models import Base - -OPERATING_SYSTEMS = {"darwin", "linux", "windows"} - - -def pytest_addoption(parser): - parser.addoption("--pool-dir", default="/data/restvirt") - - -@pytest.fixture(scope="session") -def pool_dir(pytestconfig): - return pytestconfig.getoption("pool_dir") - - -def pytest_configure(config): - for os in OPERATING_SYSTEMS: - config.addinivalue_line("markers", f"{os}: mark tests to only run on {os} operating system") - - -def pytest_runtest_setup(item): - supported_platforms = OPERATING_SYSTEMS.intersection(mark.name for mark in item.iter_markers()) - plat = sys.platform - if supported_platforms and plat not in supported_platforms: - pytest.skip("cannot run on platform {}".format(plat)) - - -def pytest_collection_modifyitems(items): - for item in items: - os = item.nodeid.split("_")[-1] - if os in OPERATING_SYSTEMS: - item.add_marker(os) - - -@event.listens_for(Engine, "connect") -def set_sqlite_pragma(dbapi_connection, connection_record): - cursor = dbapi_connection.cursor() - cursor.execute("PRAGMA foreign_keys=ON") - cursor.close() - - -@pytest.fixture -def engine(): - engine = create_engine( - "sqlite:///:memory:", - connect_args={"check_same_thread": False}, - poolclass=StaticPool, - echo=True, - future=True, - ) - Base.metadata.create_all(engine) - yield engine - Base.metadata.drop_all(engine) - - -@pytest.fixture -def session_factory(engine): - return sessionmaker(engine, future=True) - - -@pytest.fixture -def dns_controller(session_factory): - return DNSController(session_factory) - - -class DaemonDummy(daemon_pb2_grpc.DaemonServiceServicer): - def SyncRoutes(self, request, context): - return empty_pb2.Empty() - - -@pytest.fixture -def controller_channel(session_factory, dns_controller): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), interceptors=[]) - port = server.add_insecure_port("localhost:0") - channel = grpc.insecure_channel(f"localhost:{port}") - - host_controller = HostController(session_factory) - controller_pb2_grpc.add_ControllerServiceServicer_to_server( - Controller(session_factory, host_controller, dns_controller), - server, - ) - host_pb2_grpc.add_HostServiceServicer_to_server( - HostService(host_controller, session_factory), server - ) - - dns_controller.start() - server.start() - yield channel - server.stop(1) - dns_controller.stop() - - -@pytest.fixture -def host_client(controller_channel): - return host_pb2_grpc.HostServiceStub(controller_channel) - - -@pytest.fixture -def controller_client_dummy(controller_channel, host_client): - daemon = grpc.server(futures.ThreadPoolExecutor(max_workers=10), interceptors=[]) - daemon_port = daemon.add_insecure_port("localhost:0") - - daemon_pb2_grpc.add_DaemonServiceServicer_to_server(DaemonDummy(), daemon) - - token = host_client.CreateBootstrapToken(host_pb2.CreateBootstrapTokenRequest()).token - host_client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name="test", - address=f"localhost:{daemon_port}", - ), - ) - ) - - daemon.start() - yield controller_pb2_grpc.ControllerServiceStub(controller_channel) - daemon.stop(1) - - -@pytest.fixture -def controller_client(session_factory, controller_channel, host_client): - from minivirt.daemon import DaemonService - from minivirt.port_forwarding import IPTablesPortForwardingSynchronizer - from minivirt.utils import UnaryUnaryInterceptor - - daemon = grpc.server( - futures.ThreadPoolExecutor(max_workers=10), interceptors=[UnaryUnaryInterceptor()] - ) - daemon_port = daemon.add_insecure_port("localhost:0") - - daemon_service = DaemonService( - session_factory, - IPTablesPortForwardingSynchronizer( - controller_pb2_grpc.ControllerServiceStub(controller_channel), - ), - controller_channel, - ) - daemon_pb2_grpc.add_DaemonServiceServicer_to_server( - daemon_service, - daemon, - ) - daemon_service.sync() - - token = host_client.CreateBootstrapToken(host_pb2.CreateBootstrapTokenRequest()).token - host_client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name="test", - address=f"localhost:{daemon_port}", - ), - ) - ) - - daemon.start() - yield controller_pb2_grpc.ControllerServiceStub(controller_channel) - daemon.stop(1) - - -@contextlib.contextmanager -def dummy_controller(dns_port=53): - engine = create_engine( - "sqlite:///:memory:", - connect_args={"check_same_thread": False}, - poolclass=StaticPool, - echo=False, - future=True, - ) - Base.metadata.create_all(engine) - session_factory = sessionmaker(engine) - - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), interceptors=[]) - port = server.add_insecure_port("localhost:0") - controller_channel = grpc.insecure_channel(f"localhost:{port}") - - dns_controller = DNSController(session_factory) - - host_controller = HostController(session_factory) - controller_pb2_grpc.add_ControllerServiceServicer_to_server( - Controller(session_factory, host_controller, dns_controller), - server, - ) - host_pb2_grpc.add_HostServiceServicer_to_server( - HostService(host_controller, session_factory), server - ) - - dns_controller.start(dns_port) - server.start() - - daemon = grpc.server(futures.ThreadPoolExecutor(max_workers=10), interceptors=[]) - daemon_port = daemon.add_insecure_port("localhost:0") - - daemon_pb2_grpc.add_DaemonServiceServicer_to_server(DaemonDummy(), daemon) - - host_client = host_pb2_grpc.HostServiceStub(controller_channel) - token = host_client.CreateBootstrapToken(host_pb2.CreateBootstrapTokenRequest()).token - host_client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name="test", - address=f"localhost:{daemon_port}", - ), - ) - ) - - daemon.start() - - try: - yield controller_pb2_grpc.ControllerServiceStub(controller_channel) - finally: - daemon.stop(1) - server.stop(1) - dns_controller.stop() - Base.metadata.drop_all(engine) diff --git a/tests/unit/test_dns.py b/tests/unit/test_dns.py deleted file mode 100644 index e00ca7a..0000000 --- a/tests/unit/test_dns.py +++ /dev/null @@ -1,151 +0,0 @@ -import grpc -import pytest -from dnslib import CLASS, QTYPE, RCODE, RR, DNSQuestion, DNSRecord -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -from sqlalchemy.pool import StaticPool - -from minivirt import dns_pb2, dns_pb2_grpc, models -from minivirt.dns_controller import DNSController -from minivirt.models import Base - -from .conftest import dummy_controller - - -class DNSClient: - def __init__(self, host="localhost", port=53): - self.host = host - self.port = port - - def query(self, name, qtype, qclass="IN"): - q = DNSRecord(q=DNSQuestion(name, getattr(QTYPE, qtype), getattr(CLASS, qclass))) - raw = q.send(self.host, self.port) - return DNSRecord.parse(raw) - - -@pytest.fixture -def dns_client(dns_controller): - yield DNSClient() - - -@pytest.fixture -def client(controller_client_dummy): - return controller_client_dummy - - -def test_dns_put(client: dns_pb2_grpc.DNSStub, dns_client): - client.PutDNSRecord( - dns_pb2.PutDNSRecordRequest( - dns_record=dns_pb2.DNSRecord( - name="mydomain.internal", - type="A", - ttl=60, - records=["192.168.1.1"], - ) - ) - ) - records = client.ListDNSRecords(dns_pb2.ListDNSRecordsRequest()).dns_records - assert len(records) == 1 - assert dns_client.query("mydomain.internal", "A").rr == RR.fromZone( - "mydomain.internal. 60 IN A 192.168.1.1" - ) - - client.PutDNSRecord( - dns_pb2.PutDNSRecordRequest( - dns_record=dns_pb2.DNSRecord( - name="mydomain.internal", - type="A", - ttl=120, - records=["192.168.1.2"], - ) - ) - ) - records = client.ListDNSRecords(dns_pb2.ListDNSRecordsRequest()).dns_records - assert len(records) == 1 - assert dns_client.query("mydomain.internal", "A").rr == RR.fromZone( - "mydomain.internal. 120 IN A 192.168.1.2" - ) - - -def test_dns_get(client: dns_pb2_grpc.DNSStub): - client.PutDNSRecord( - dns_pb2.PutDNSRecordRequest( - dns_record=dns_pb2.DNSRecord( - name="mydomain.internal", - type="A", - ttl=120, - records=["192.168.1.2"], - ) - ) - ) - - record = client.GetDNSRecord(dns_pb2.DNSRecordIdentifier(name="mydomain.internal", type="A")) - assert record.records == ["192.168.1.2"] - - with pytest.raises(grpc.RpcError) as e: - client.GetDNSRecord(dns_pb2.DNSRecordIdentifier(name="non-existing.internal", type="A")) - assert e.value.code() == grpc.StatusCode.NOT_FOUND - - -# def test_dns_forward(client: dns_pb2_grpc.DNSStub, dns_client): -# assert dns_client.query("google.com", "A").header.rcode == RCODE.NOERROR -# assert dns_client.query("non-existing.internal", "A").header.rcode == RCODE.NXDOMAIN - - -def test_dns_delete(client: dns_pb2_grpc.DNSStub): - client.PutDNSRecord( - dns_pb2.PutDNSRecordRequest( - dns_record=dns_pb2.DNSRecord( - name="mydomain.internal", - type="A", - ttl=120, - records=["192.168.1.2"], - ) - ) - ) - - client.DeleteDNSRecord(dns_pb2.DNSRecordIdentifier(name="mydomain.internal", type="A")) - records = client.ListDNSRecords(dns_pb2.ListDNSRecordsRequest()).dns_records - assert len(records) == 0 - - -def test_dns_delegation(): - engine = create_engine( - "sqlite:///:memory:", - connect_args={"check_same_thread": False}, - poolclass=StaticPool, - echo=False, - future=True, - ) - Base.metadata.create_all(engine) - sessfact = sessionmaker(engine) - upstream_dns = DNSController(sessfact) - with sessfact() as session: - session.merge( - models.DNSRecord(name="test.delegated.internal", type="A", records=["192.168.11.11"]) - ) - session.commit() - upstream_dns.start() - - with dummy_controller(dns_port=30053) as client: - client.PutDNSRecord( - dns_pb2.PutDNSRecordRequest( - dns_record=dns_pb2.DNSRecord( - name="delegated.internal", - type="NS", - ttl=120, - records=["127.0.0.1"], - ) - ) - ) - - dns_client = DNSClient(port=30053) - resp = dns_client.query("test.delegated.internal", "A") - assert len(resp.ar) == 0 - assert len(resp.auth) == 1 - assert resp.auth[0].rtype == QTYPE.NS - assert resp.auth[0].rname == "delegated.internal" - assert str(resp.auth[0].rdata) == "127.0.0.1." - assert not resp.header.ra - - upstream_dns.stop() diff --git a/tests/unit/test_domain.py b/tests/unit/test_domain.py deleted file mode 100644 index 3558f2e..0000000 --- a/tests/unit/test_domain.py +++ /dev/null @@ -1,110 +0,0 @@ -import datetime -from time import sleep -from urllib.parse import urljoin -from urllib.request import urlopen - -import pytest - -from minivirt import domain_pb2, domain_pb2_grpc - - -@pytest.fixture -def conn(): - import libvirt - - conn = libvirt.open("qemu:///system?socket=/var/run/libvirt/libvirt-sock") - yield conn - conn.close() - - -@pytest.fixture -def client(controller_client, pool_dir, conn): - yield controller_client - - img_pool = conn.storagePoolLookupByName("restvirtimages") - for vol in img_pool.listAllVolumes(): - vol.delete() - img_pool.destroy() - img_pool.delete() - img_pool.undefine() - - for dom in conn.listAllDomains(): - try: - dom.destroy() - except: - pass - dom.undefine() - - -def test_libvirt_linux(): - import libvirt - - libvirt.getVersion() - - -def test_network_linux(client: domain_pb2_grpc.DomainServiceStub): - network = client.CreateNetwork( - domain_pb2.CreateNetworkRequest( - host="test", - network=domain_pb2.Network( - name="restvirt", - cidr="192.168.69.0/24", - ), - ) - ) - - resp = client.GetNetwork(domain_pb2.GetNetworkRequest(host="test", uuid=network.uuid)) - assert resp.name == "restvirt" - assert resp.cidr == "192.168.69.0/24" - - client.DeleteNetwork(domain_pb2.DeleteNetworkRequest(host="test", uuid=network.uuid)) - - -# def test_create_domain_linux(client: domain_pb2_grpc.DomainServiceStub): -# network = client.CreateNetwork( -# domain_pb2.CreateNetworkRequest( -# network=domain_pb2.Network( -# name="restvirt", -# cidr="192.168.69.0/24", -# ) -# ) -# ) -# dom = client.CreateDomain( -# domain_pb2.CreateDomainRequest( -# host="test", -# domain=domain_pb2.Domain( -# name="test", -# vcpu=1, -# memory=512, -# private_ip="192.168.69.69", -# network=network.name, -# user_data="""#cloud-config -# -# packages: -# - nginx -# -# runcmd: -# - service nginx restart -# """, -# ), -# ) -# ) -# -# response = wait_for_http("http://192.168.69.69") -# assert "Welcome to nginx!" in response -# -# client.DeleteDomain(domain_pb2.DeleteDomainRequest(host="test", uuid=dom.uuid)) -# client.DeleteNetwork(domain_pb2.DeleteNetworkRequest(uuid=network.uuid)) -# -# -# def wait_for_http(server, path="/", timeout=datetime.timedelta(seconds=180)): -# end_time = datetime.datetime.now() + timeout -# while True: -# try: -# with urlopen(urljoin(server, path)) as resp: -# return resp.read().decode() -# except: -# now = datetime.datetime.now() -# if now >= end_time: -# raise Exception("Timed out") -# sleep(min((end_time - now).total_seconds(), 10)) diff --git a/tests/unit/test_host.py b/tests/unit/test_host.py deleted file mode 100644 index ab8344d..0000000 --- a/tests/unit/test_host.py +++ /dev/null @@ -1,52 +0,0 @@ -from datetime import datetime, timedelta - -import grpc -import pytest - -from minivirt import host_pb2, host_pb2_grpc - - -@pytest.fixture -def client(host_client): - return host_client - - -def test_register(client: host_pb2_grpc.HostServiceStub): - assert len(client.ListHosts(host_pb2.ListHostsRequest()).hosts) == 0 - - token = client.CreateBootstrapToken(host_pb2.CreateBootstrapTokenRequest()).token - client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name="yourmom", - address="localhost:8333", - ), - ) - ) - hosts = client.ListHosts(host_pb2.ListHostsRequest()).hosts - assert len(hosts) == 1 - host = hosts[0] - assert host.address == "localhost:8333" - - client.Deregister(host_pb2.Host(name="yourmom")) - assert len(client.ListHosts(host_pb2.ListHostsRequest()).hosts) == 0 - - -def test_register_expired(client: host_pb2_grpc.HostServiceStub): - token = client.CreateBootstrapToken( - host_pb2.CreateBootstrapTokenRequest( - expires_at=(datetime.utcnow() - timedelta(seconds=10)).isoformat() - ) - ).token - with pytest.raises(grpc.RpcError) as e: - client.Register( - host_pb2.RegisterHostRequest( - token=token, - host=host_pb2.Host( - name="yourmom", - address="localhost:8333", - ), - ) - ) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py deleted file mode 100644 index f445200..0000000 --- a/tests/unit/test_image.py +++ /dev/null @@ -1,35 +0,0 @@ -from ipaddress import ip_address, ip_network - -import pytest - -from minivirt.image import ( - create_cloud_config_image, - read_ip_from_cloud_config_image, - read_user_data_from_cloud_config_image, -) - - -@pytest.fixture -def data(): - return create_cloud_config_image( - domain_id="domain_id", - user_data="hello world", - mac="mac_address", - network=ip_network("192.168.1.0/24"), - network6=ip_network("fd8d:dd47:05bc:5307::/64"), - address=ip_address("192.168.1.43"), - address6=ip_address("fd8d:dd47:05bc:5307::10"), - gateway=ip_address("192.168.1.1"), - gateway6=ip_address("fd8d:dd47:05bc:5307::1"), - name="name", - ) - - -def test_read_ip(data): - ip = read_ip_from_cloud_config_image(data) - assert ip == "192.168.1.43" - - -def test_read_user_data(data): - user_data = read_user_data_from_cloud_config_image(data) - assert user_data == "hello world" diff --git a/tests/unit/test_port_forwarding.py b/tests/unit/test_port_forwarding.py deleted file mode 100644 index 8a7c9a7..0000000 --- a/tests/unit/test_port_forwarding.py +++ /dev/null @@ -1,141 +0,0 @@ -import grpc -import pytest - -from minivirt import port_forwarding_pb2, port_forwarding_pb2_grpc - - -@pytest.fixture -def client(controller_client): - return controller_client - - -def test_port_forwarding_get_linux(client: port_forwarding_pb2_grpc.PortForwardingServiceStub): - identifier = port_forwarding_pb2.PortForwardingIdentifier( - host="test", protocol="tcp", source_port=2020 - ) - with pytest.raises(grpc.RpcError) as e: - client.GetPortForwarding(identifier) - assert e.value.code() == grpc.StatusCode.NOT_FOUND - - fwd = port_forwarding_pb2.PortForwarding( - protocol="tcp", - source_port=2020, - target_ip="192.168.1.69", - target_port=2021, - ) - client.PutPortForwarding( - port_forwarding_pb2.PutPortForwardingRequest(host="test", port_forwarding=fwd) - ) - forwarding = client.GetPortForwarding(identifier) - assert forwarding.target_ip == "192.168.1.69" - assert forwarding.target_port == 2021 - - -def test_port_forwarding_put_linux(client: port_forwarding_pb2_grpc.PortForwardingServiceStub): - fwd = port_forwarding_pb2.PortForwarding( - protocol="tcp", - source_port=2020, - target_ip="192.168.1.69", - target_port=2021, - ) - client.PutPortForwarding( - port_forwarding_pb2.PutPortForwardingRequest(host="test", port_forwarding=fwd) - ) - fwds = client.ListPortForwardings( - port_forwarding_pb2.ListPortForwardingsRequest(host="test") - ).port_forwardings - assert len(fwds) == 1 - assert fwds[0].target_ip == "192.168.1.69" - - fwds = client.ListPortForwardings( - port_forwarding_pb2.ListPortForwardingsRequest(host="test") - ).port_forwardings - assert len(fwds) == 1 - assert fwds[0].target_ip == "192.168.1.69" - - fwd.target_ip = "192.168.1.70" - client.PutPortForwarding( - port_forwarding_pb2.PutPortForwardingRequest(host="test", port_forwarding=fwd) - ) - fwds = client.ListPortForwardings( - port_forwarding_pb2.ListPortForwardingsRequest(host="test") - ).port_forwardings - assert len(fwds) == 1 - assert fwds[0].target_ip == "192.168.1.70" - - -def test_port_forwarding_linux(client: port_forwarding_pb2_grpc.PortForwardingServiceStub): - import nftables - - fwd = port_forwarding_pb2.PortForwarding( - protocol="tcp", - source_port=2020, - target_ip="192.168.1.69", - target_port=2021, - ) - client.PutPortForwarding( - port_forwarding_pb2.PutPortForwardingRequest(host="test", port_forwarding=fwd) - ) - - table_name = "restvirt" - nft = nftables.Nftables() - nft.set_json_output(True) - nft.set_stateless_output(True) - - _, output, _ = nft.json_cmd( - { - "nftables": [ - { - "list": { - "table": { - "family": "inet", - "name": table_name, - } - } - } - ] - } - ) - output = output["nftables"] - all_rules = [rule["rule"] for rule in output if "rule" in rule] - - rules = [rule for rule in all_rules if rule["chain"] == "forward"] - assert len(rules) == 1 - rule = rules[0] - assert rule["expr"] == [ - { - "match": { - "left": {"payload": {"field": "dport", "protocol": "tcp"}}, - "op": "==", - "right": 2021, - } - }, - { - "match": { - "left": {"payload": {"field": "daddr", "protocol": "ip"}}, - "op": "==", - "right": "192.168.1.69", - } - }, - {"counter": None}, - {"accept": None}, - ] - - rules = [rule for rule in all_rules if rule["chain"] == "prerouting"] - assert len(rules) == 1 - rule = rules[0] - assert rule["expr"] == [ - { - "match": { - "left": {"payload": {"field": "dport", "protocol": "tcp"}}, - "op": "==", - "right": 2020, - } - }, - {"counter": None}, - {"dnat": {"addr": "192.168.1.69", "family": "ip", "port": 2021}}, - ] - - client.DeletePortForwarding( - port_forwarding_pb2.PortForwardingIdentifier(host="test", protocol="tcp", source_port=2020) - ) diff --git a/tests/unit/test_route.py b/tests/unit/test_route.py deleted file mode 100644 index 3a8f363..0000000 --- a/tests/unit/test_route.py +++ /dev/null @@ -1,153 +0,0 @@ -import pytest -from pyroute2 import IPRoute - -from minivirt import controller_pb2_grpc, route_pb2 - - -@pytest.fixture -def client(controller_client_dummy): - return controller_client_dummy - - -def test_id_generation(client: controller_pb2_grpc.ControllerServiceStub): - req = route_pb2.CreateRouteTableRequest(route_table=route_pb2.RouteTable(name="XAXAXA")) - creates = [client.CreateRouteTable(req) for _ in range(3)] - ids = [resp.id for resp in creates] - client.DeleteRouteTable(route_pb2.RouteTableIdentifier(id=ids[1])) - resp = client.CreateRouteTable(req) - assert resp.id == ids[1] - - for _ in range(98): - client.CreateRouteTable(req) - - with pytest.raises(Exception): - client.CreateRouteTable(req) - - -def test_route_update(client: controller_pb2_grpc.ControllerServiceStub): - req = route_pb2.CreateRouteTableRequest(route_table=route_pb2.RouteTable(name="XAXAXA")) - resp = client.CreateRouteTable(req) - route_table_id = resp.id - client.PutRoute( - route_pb2.PutRouteRequest( - route=route_pb2.Route( - route_table_id=route_table_id, - destination="10.6.1.0/24", - gateways=["192.168.0.1"], - ) - ) - ) - client.PutRoute( - route_pb2.PutRouteRequest( - route=route_pb2.Route( - route_table_id=route_table_id, - destination="10.6.1.0/24", - gateways=["192.168.0.2", "192.168.0.3"], - ) - ) - ) - routes = client.ListRoutes(route_pb2.ListRoutesRequest(route_table_id=route_table_id)).routes - assert len(routes) == 1 - assert sorted(routes[0].gateways) == ["192.168.0.2", "192.168.0.3"] - - -def test_route_delete(client: controller_pb2_grpc.ControllerServiceStub): - req = route_pb2.CreateRouteTableRequest(route_table=route_pb2.RouteTable(name="XAXAXA")) - resp = client.CreateRouteTable(req) - route_table_id = resp.id - route = client.PutRoute( - route_pb2.PutRouteRequest( - route=route_pb2.Route( - route_table_id=route_table_id, - destination="10.6.1.0/24", - gateways=["192.168.0.1"], - ) - ) - ) - routes = client.ListRoutes(route_pb2.ListRoutesRequest(route_table_id=route_table_id)).routes - assert len(routes) == 1 - - client.DeleteRoute( - route_pb2.RouteIdentifier( - route_table_id=route.route_table_id, - destination=route.destination, - ) - ) - routes = client.ListRoutes(route_pb2.ListRoutesRequest(route_table_id=route_table_id)).routes - assert len(routes) == 0 - - client.DeleteRoute( - route_pb2.RouteIdentifier( - route_table_id=route.route_table_id, - destination=route.destination, - ) - ) - - -def test_route_table_delete(client: controller_pb2_grpc.ControllerServiceStub): - req = route_pb2.CreateRouteTableRequest(route_table=route_pb2.RouteTable(name="XAXAXA")) - resp = client.CreateRouteTable(req) - route_table_id = resp.id - client.PutRoute( - route_pb2.PutRouteRequest( - route=route_pb2.Route( - route_table_id=route_table_id, - destination="10.6.1.0/24", - gateways=["192.168.0.1"], - ) - ) - ) - - client.DeleteRouteTable(route_pb2.RouteTableIdentifier(id=route_table_id)) - routes = client.ListRoutes(route_pb2.ListRoutesRequest(route_table_id=route_table_id)).routes - assert len(routes) == 0 - - client.DeleteRouteTable(route_pb2.RouteTableIdentifier(id=route_table_id)) - - -@pytest.fixture -def rtnl_api(): - with IPRoute() as ip: - yield ip - - -@pytest.fixture -def client_iproute(controller_client, rtnl_api): - rtnl_api.link("add", ifname="restvirtbr0", kind="dummy") - dev = rtnl_api.link_lookup(ifname="restvirtbr0")[0] - rtnl_api.addr("add", index=dev, address="10.69.69.0", mask=24) - rtnl_api.link("set", index=dev, state="up") - - yield controller_client - - rtnl_api.link("del", ifname="restvirtbr0") - - -def test_route_linux(client_iproute: controller_pb2_grpc.ControllerServiceStub, rtnl_api: IPRoute): - client = client_iproute - req = route_pb2.CreateRouteTableRequest(route_table=route_pb2.RouteTable(name="XAXAXA")) - resp = client.CreateRouteTable(req) - route_table_id = resp.id - route = client.PutRoute( - route_pb2.PutRouteRequest( - route=route_pb2.Route( - route_table_id=route_table_id, - destination="10.69.42.0/24", - gateways=["10.69.69.1"], - ) - ) - ) - - r = rtnl_api.route("get", dst="10.69.42.1")[0] - assert r.get_attr("RTA_GATEWAY") == "10.69.69.1" - - client.DeleteRoute( - route_pb2.RouteIdentifier( - route_table_id=route.route_table_id, - destination=route.destination, - ) - ) - assert len(rtnl_api.get_routes(table=route_table_id)) == 0 - - client.DeleteRouteTable(route_pb2.RouteTableIdentifier(id=route_table_id)) - assert len(rtnl_api.get_rules(priority=route_table_id)) == 0 diff --git a/virtuerl/.gitignore b/virtuerl/.gitignore deleted file mode 100644 index 78647f9..0000000 --- a/virtuerl/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -*.iml -.DS_Store -.vagrant/ -khepri*/ - -.rebar3 -_build -_checkouts -_vendor -.eunit -*.o -*.beam -*.plt -*.swp -*.swo -.erlang.cookie -ebin -log -erl_crash.dump -.rebar -logs -#.idea -#*.iml -rebar3.crashdump -*~ diff --git a/virtuerl/.idea/.gitignore b/virtuerl/.idea/.gitignore deleted file mode 100644 index 24de6c7..0000000 --- a/virtuerl/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -misc.xml -rebar.xml diff --git a/virtuerl/.idea/codeStyles/Project.xml b/virtuerl/.idea/codeStyles/Project.xml deleted file mode 100644 index 919ce1f..0000000 --- a/virtuerl/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/virtuerl/.idea/codeStyles/codeStyleConfig.xml b/virtuerl/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/virtuerl/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/virtuerl/.idea/modules.xml b/virtuerl/.idea/modules.xml deleted file mode 100644 index d627cff..0000000 --- a/virtuerl/.idea/modules.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/virtuerl/.idea/vcs.xml b/virtuerl/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/virtuerl/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/virtuerl/LICENSE.md b/virtuerl/LICENSE.md deleted file mode 100644 index b1ceda4..0000000 --- a/virtuerl/LICENSE.md +++ /dev/null @@ -1,186 +0,0 @@ -# Apache License -Version 2.0, January 2004 - -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -## 1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -## 2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -## 3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -## 4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -1. You must give any other recipients of the Work or Derivative Works a copy of - this License; and - -2. You must cause any modified files to carry prominent notices stating that - You changed the files; and - -3. You must retain, in the Source form of any Derivative Works that You - distribute, all copyright, patent, trademark, and attribution notices from - the Source form of the Work, excluding those notices that do not pertain to - any part of the Derivative Works; and - -4. If the Work includes a "NOTICE" text file as part of its distribution, then - any Derivative Works that You distribute must include a readable copy of the - attribution notices contained within such NOTICE file, excluding those - notices that do not pertain to any part of the Derivative Works, in at least - one of the following places: within a NOTICE text file distributed as part - of the Derivative Works; within the Source form or documentation, if - provided along with the Derivative Works; or, within a display generated by - the Derivative Works, if and wherever such third-party notices normally - appear. The contents of the NOTICE file are for informational purposes only - and do not modify the License. You may add Your own attribution notices - within Derivative Works that You distribute, alongside or as an addendum to - the NOTICE text from the Work, provided that such additional attribution - notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -## 5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -## 6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -## 7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, NON- -INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -## 8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -## 9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -Copyright 2023, Ilya Verbitskiy . - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/virtuerl/README.md b/virtuerl/README.md deleted file mode 100644 index 8f86b0e..0000000 --- a/virtuerl/README.md +++ /dev/null @@ -1,57 +0,0 @@ -virtuerl -===== - -An OTP application - -# Required packages -```sh -sudo apt install ovmf swtpm -``` - -# Windows Guests - -## Disable boot prompt -```sh -sudo mount -o loop Win11_23H2_EnglishInternational_x64v2.iso /mnt/win - -genisoimage \ - --allow-limited-size \ - -no-emul-boot \ - -b "boot/etfsboot.com" \ - -boot-load-seg 0 \ - -boot-load-size 8 \ - -eltorito-alt-boot \ - -no-emul-boot \ - -e "efi/microsoft/boot/efisys_noprompt.bin" \ - -boot-load-size 1 \ - -iso-level 4 \ - -udf \ - -o "win.iso" \ - /mnt/win/ -``` - -# Running - -On the server - -Make sure IP forwarding is enabled (`/etc/sysctl.conf`) -``` -# Uncomment the next line to enable packet forwarding for IPv4 -net.ipv4.ip_forward=1 -# Uncomment the next line to enable packet forwarding for IPv6 -net.ipv6.conf.all.forwarding=1 -``` -Run `sysctl -w` to commit changes. - -```sh -sudo -s ./erts-13.1.5/bin/erl -mode embedded -boot releases/0.7.0+build.61.ref8fc0b7e/start -config releases/0.7.0+build.61.ref8fc0b7e/sys.config -proto_dist inet6_tcp -name verbit@verbit.in-berlin.de -setcookie abcdef -``` - -Locally -```sh -rebar3 compile -erl -name moi -proto_dist inet6_tcp -setcookie abcdef -pa _build/default/lib/*/ebin -hidden -(moi@t460s.lan)1> net_adm:ping('virtuerl@a.in6.dev'). -pong -(moi@t460s.lan)2> virtuerl_ui:start('virtuerl@a.in6.dev'). -``` diff --git a/virtuerl/Vagrantfile b/virtuerl/Vagrantfile deleted file mode 100644 index 543bf43..0000000 --- a/virtuerl/Vagrantfile +++ /dev/null @@ -1,77 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "debian/bookworm64" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "../", "/restvirt" - - # Disable the default share of the current code directory. Doing this - # provides improved isolation between the vagrant box and your host - # by making sure your Vagrantfile isn't accessable to the vagrant box. - # If you use this you may want to enable additional shared subfolders as - # shown above. - config.vm.synced_folder ".", "/vagrant", disabled: true - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/virtuerl/bird.conf b/virtuerl/bird.conf deleted file mode 100644 index 4351773..0000000 --- a/virtuerl/bird.conf +++ /dev/null @@ -1,171 +0,0 @@ -# This is a basic configuration file, which contains boilerplate options and -# some basic examples. It allows the BIRD daemon to start but will not cause -# anything else to happen. -# -# Please refer to the BIRD User's Guide documentation, which is also available -# online at http://bird.network.cz/ in HTML format, for more information on -# configuring BIRD and adding routing protocols. - -# Configure logging -# log syslog all; -log stderr all; -# log "/var/log/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug }; - -# Set router ID. It is a unique identification of your router, usually one of -# IPv4 addresses of the router. It is recommended to configure it explicitly. -# router id 198.51.100.1; - -# Turn on global debugging of all protocols (all messages or just selected classes) -# debug protocols all; -# debug protocols { events, states }; - -# Turn on internal watchdog -# watchdog warning 5 s; -# watchdog timeout 30 s; - -# You can define your own constants -# define my_asn = 65000; -# define my_addr = 198.51.100.1; - -# Tables master4 and master6 are defined by default -# ipv4 table master4; -# ipv6 table master6; - -# Define more tables, e.g. for policy routing or as MRIB -# ipv4 table mrib4; -# ipv6 table mrib6; - -# The Device protocol is not a real routing protocol. It does not generate any -# routes and it only serves as a module for getting information about network -# interfaces from the kernel. It is necessary in almost any configuration. -protocol device { -} - -# The direct protocol is not a real routing protocol. It automatically generates -# direct routes to all network interfaces. Can exist in as many instances as you -# wish if you want to populate multiple routing tables with direct routes. -protocol direct { - disabled; # Disable by default - ipv4; # Connect to default IPv4 table - ipv6; # ... and to default IPv6 table -} - -# The Kernel protocol is not a real routing protocol. Instead of communicating -# with other routers in the network, it performs synchronization of BIRD -# routing tables with the OS kernel. One instance per table. -protocol kernel { - ipv4 { # Connect protocol to IPv4 table by channel -# table master4; # Default IPv4 table is master4 -# import all; # Import to table, default is import all - export all; # Export to protocol. default is export none - }; -# learn; # Learn alien routes from the kernel -# kernel table 10; # Kernel table to synchronize with (default: main) -} - -# Another instance for IPv6, skipping default options -protocol kernel { - ipv6 { export all; }; -} - -# Static routes (Again, there can be multiple instances, for different address -# families and to disable/enable various groups of static routes on the fly). -protocol static { - ipv4; # Again, IPv4 channel with default options - -# route 0.0.0.0/0 via 198.51.100.10; -# route 192.0.2.0/24 blackhole; -# route 10.0.0.0/8 unreachable; -# route 10.2.0.0/24 via "eth0"; -# # Static routes can be defined with optional attributes -# route 10.1.1.0/24 via 198.51.100.3 { rip_metric = 3; }; -# route 10.1.2.0/24 via 198.51.100.3 { ospf_metric1 = 100; }; -# route 10.1.3.0/24 via 198.51.100.4 { ospf_metric2 = 100; }; -} - -include "birderl.conf"; - -protocol bgp { - local as 65000 port 9179; - neighbor range 192.168.0.0/16 as 65001; - passive; - ipv4 { - import all; - export all; - }; -} - -# Define simple filter as an example for BGP import filter -# See https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering for more examples -# filter rt_import -# { -# if bgp_path.first != 64496 then accept; -# if bgp_path.len > 64 then accept; -# if bgp_next_hop != from then accept; -# reject; -# } - -# BGP example, explicit name 'uplink1' is used instead of default 'bgp1' -# protocol bgp uplink1 { -# description "My BGP uplink"; -# local 198.51.100.1 as 65000; -# neighbor 198.51.100.10 as 64496; -# hold time 90; # Default is 240 -# password "secret"; # Password used for MD5 authentication -# -# ipv4 { # regular IPv4 unicast (1/1) -# import filter rt_import; -# export where source ~ [ RTS_STATIC, RTS_BGP ]; -# }; -# -# ipv6 { # regular IPv6 unicast (2/1) -# import filter rt_import; -# export filter { # The same as 'where' expression above -# if source ~ [ RTS_STATIC, RTS_BGP ] -# then accept; -# else reject; -# }; -# }; -# -# ipv4 multicast { # IPv4 multicast topology (1/2) -# table mrib4; # explicit IPv4 table -# import filter rt_import; -# export all; -# }; -# -# ipv6 multicast { # IPv6 multicast topology (2/2) -# table mrib6; # explicit IPv6 table -# import filter rt_import; -# export all; -# }; -#} - -# Template example. Using templates to define IBGP route reflector clients. -# template bgp rr_clients { -# local 10.0.0.1 as 65000; -# neighbor as 65000; -# rr client; -# rr cluster id 1.0.0.1; -# -# ipv4 { -# import all; -# export where source = RTS_BGP; -# }; -# -# ipv6 { -# import all; -# export where source = RTS_BGP; -# }; -# } -# -# protocol bgp client1 from rr_clients { -# neighbor 10.0.1.1; -# } -# -# protocol bgp client2 from rr_clients { -# neighbor 10.0.2.1; -# } -# -# protocol bgp client3 from rr_clients { -# neighbor 10.0.3.1; -# } diff --git a/virtuerl/erlang_ls.config b/virtuerl/erlang_ls.config deleted file mode 100644 index d7edc4a..0000000 --- a/virtuerl/erlang_ls.config +++ /dev/null @@ -1,9 +0,0 @@ -apps_dirs: - - "_build/default/lib/*" -include_dirs: - - "include" - - "_build/default/lib/*/include" - - "_build/default/lib" - - "_build/default/lib/khepri" -deps_dirs: - - "_build/default/lib/*" From 6656265fdd746de8cdfa9cf1401d59f0638c290b Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 22:56:38 +0200 Subject: [PATCH 46/51] run tests on push --- .github/workflows/virtuerl.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index 50619c7..ae4bf4c 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -19,6 +19,9 @@ jobs: run: | sudo apt update sudo apt install -y rebar3 g++ tree + - name: Test + run: | + sudo rebar3 ct - name: Create tar run: | sudo rebar3 tar From dc43fb2870d438ef3954b63cbc26f767204a2c03 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 23:28:50 +0200 Subject: [PATCH 47/51] ghac: fix errors --- src/virtuerl_ghac.erl | 11 ++++------- src/virtuerl_sup.erl | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/virtuerl_ghac.erl b/src/virtuerl_ghac.erl index 36d9901..d641fdc 100644 --- a/src/virtuerl_ghac.erl +++ b/src/virtuerl_ghac.erl @@ -15,17 +15,14 @@ code_change/3]). -define(SERVER, ?MODULE). - % owner="verbit", - % repo="restvirt", - % token="230b9671f90e4ff0f1f722776a6ef7e4620d97d0", base_url() -> - {ok, Org} = application:get_key(gh_org), - {ok, Repo} = application:get_key(gh_repo), + {ok, Org} = application:get_env(gh_org), + {ok, Repo} = application:get_env(gh_repo), ["https://api.github.com/repos/", Org, "/", Repo]. headers() -> - {ok, Token} = application:get_key(gh_pat), + {ok, Token} = application:get_env(gh_pat), [{"User-Agent", "terstegen"}, {"Authorization", ["Bearer ", Token]}]. pending_jobs() -> @@ -38,7 +35,7 @@ pending_jobs() -> NumJobs. list_jobs(RunId) -> - {ok, {{_, 200, _}, _Headers, JobsRaw}} = httpc:request(get, {[base_url(), "/actions/runs/", RunId, "/jobs"], headers()}, [], []), + {ok, {{_, 200, _}, _Headers, JobsRaw}} = httpc:request(get, {[base_url(), "/actions/runs/", integer_to_list(RunId), "/jobs"], headers()}, [], []), {ok, JobsJson} = thoas:decode(JobsRaw), JobsJson. diff --git a/src/virtuerl_sup.erl b/src/virtuerl_sup.erl index ebbb9db..f2757c4 100644 --- a/src/virtuerl_sup.erl +++ b/src/virtuerl_sup.erl @@ -77,7 +77,7 @@ init([]) -> ], OptionalChildSpecs = case application:get_env(gh_pat) of undefined -> []; - _ -> [{virtuerl_ghac, {virtuerl_ghac, start_link, []}, permanent, infinity, worker}] + _ -> [{virtuerl_ghac, {virtuerl_ghac, start_link, []}, permanent, infinity, worker, []}] end, {ok, {SupFlags, ChildSpecs ++ OptionalChildSpecs}}. From c6c2d17aae3656c1a3f9ea61a18b835e13567fdf Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 23:31:07 +0200 Subject: [PATCH 48/51] gha: fix default working directory --- .github/workflows/virtuerl.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index ae4bf4c..211a0a4 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -7,9 +7,6 @@ jobs: virtuerl: name: virtuerl runs-on: self-hosted - defaults: - run: - working-directory: virtuerl steps: - name: Check out code uses: actions/checkout@v4 From 75d577c4bb14df3122756e90f22560bc617ef561 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 23:34:02 +0200 Subject: [PATCH 49/51] gha: install nftables --- .github/workflows/virtuerl.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index 211a0a4..a4c7f95 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -15,7 +15,7 @@ jobs: - name: Install prerequisites run: | sudo apt update - sudo apt install -y rebar3 g++ tree + sudo apt install -y rebar3 g++ tree nftables - name: Test run: | sudo rebar3 ct From 83a8208f95aaf0bdb6e6f54f12ee5cda65c96961 Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Fri, 14 Jun 2024 23:43:07 +0200 Subject: [PATCH 50/51] gha: install ovmf swtpm --- .github/workflows/virtuerl.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index a4c7f95..46337af 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -15,7 +15,7 @@ jobs: - name: Install prerequisites run: | sudo apt update - sudo apt install -y rebar3 g++ tree nftables + sudo apt install -y rebar3 g++ tree nftables ovmf swtpm - name: Test run: | sudo rebar3 ct From 60af0d625d4f04a1826dbc1a86d65a5c6b171ead Mon Sep 17 00:00:00 2001 From: Ilya Verbitskiy Date: Sat, 15 Jun 2024 11:41:50 +0200 Subject: [PATCH 51/51] gha: enable ip forwarding --- .github/workflows/virtuerl.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/virtuerl.yaml b/.github/workflows/virtuerl.yaml index 46337af..086c2a2 100644 --- a/.github/workflows/virtuerl.yaml +++ b/.github/workflows/virtuerl.yaml @@ -16,6 +16,13 @@ jobs: run: | sudo apt update sudo apt install -y rebar3 g++ tree nftables ovmf swtpm + - name: Enable IP forwarding + run: | + sudo tee /etc/sysctl.d/99-local.conf << EOF + net.ipv4.ip_forward=1 + net.ipv6.conf.all.forwarding=1 + EOF + sudo service procps restart - name: Test run: | sudo rebar3 ct