Esempio n. 1
0
    def construction_build(self,
                           actions,
                           print_response=False,
                           ask_user=False):
        with core_api.ApiClient(self.system_config) as api_client:
            api_client = self.set_basic_auth(api_client, "admin", "admin")
            try:
                network_configuration: NetworkConfigurationResponse = self.network_configuration(
                )
                key_list: KeyListResponse = self.key_list()
                operation_groups = ValidatorConfig.build_operations(
                    actions, key_list, ask_user=ask_user)
                if len(operation_groups) == 0:
                    return

                api = construction_api.ConstructionApi(api_client)
                build_request = ConstructionBuildRequest(
                    network_identifier=network_configuration.
                    network_identifier,
                    fee_payer=key_list.public_keys[0].identifiers.
                    account_entity_identifier,
                    operation_groups=operation_groups)
                Helpers.print_request_body(build_request,
                                           "/construction/build")
                build: ConstructionBuildResponse = api.construction_build_post(
                    build_request)
                return self.handle_response(build, print_response)

            except ApiException as e:
                Helpers.handleApiException(e)
Esempio n. 2
0
 def prometheus_metrics(self):
     with system_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "metrics", "metrics")
         try:
             api = default_api.DefaultApi(api_client)
             print(api.prometheus_metrics_get())
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 3
0
 def version(self):
     with system_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = default_api.DefaultApi(api_client)
             print(api.system_version_get())
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 4
0
 def engine_configuration(self, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = engine_api.EngineApi(api_client)
             response: EngineConfigurationResponse = api.engine_configuration_post(
                 EngineConfigurationRequest(
                     self.network_configuration().network_identifier))
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 5
0
 def network_status(self, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = network_api.NetworkApi(api_client)
             response = api.network_status_post(
                 NetworkStatusRequest(
                     self.network_configuration().network_identifier))
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 6
0
 def mempool(self, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = mempool_api.MempoolApi(api_client)
             response: MempoolResponse = api.mempool_post(
                 MempoolRequest(network_identifier=self.
                                network_configuration().network_identifier))
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 7
0
 def health(self, print_response=False):
     with system_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = default_api.DefaultApi(api_client)
             health_response = api.system_health_get()
             if print_response:
                 print(health_response)
             return health_response
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 8
0
 def network_configuration(self, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = network_api.NetworkApi(api_client)
             response: NetworkConfigurationResponse = api.network_configuration_post(
                 dict())
             if print_response:
                 print(response)
             return response
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 9
0
 def vote(self, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "superadmin",
                                          "superadmin")
         try:
             api = key_api.KeyApi(api_client)
             request = UpdateVoteRequest(
                 network_identifier=self.network_configuration(
                 ).network_identifier)
             Helpers.print_request_body(request, "/key/vote")
             response: UpdateVoteResponse = api.key_vote_post(request)
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 10
0
 def entity(self, entity_identifier, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = entity_api.EntityApi(api_client)
             entityRequest = EntityRequest(
                 network_identifier=self.network_configuration(
                 ).network_identifier,
                 entity_identifier=entity_identifier)
             Helpers.print_request_body(entityRequest, "/entity")
             response: EntityResponse = api.entity_post(entityRequest)
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 11
0
 def construction_submit(self, signed_transaction, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "admin", "admin")
         try:
             api = construction_api.ConstructionApi(api_client)
             network_configuration: NetworkConfigurationResponse = self.network_configuration(
             )
             request = ConstructionSubmitRequest(
                 network_identifier=network_configuration.
                 network_identifier,
                 signed_transaction=signed_transaction)
             Helpers.print_request_body(request, "/construction/submit")
             response = api.construction_submit_post(request)
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)
Esempio n. 12
0
 def key_sign(self, unsigned_transaction, print_response=False):
     with core_api.ApiClient(self.system_config) as api_client:
         api_client = self.set_basic_auth(api_client, "superadmin",
                                          "superadmin")
         try:
             network_configuration: NetworkConfigurationResponse = self.network_configuration(
             )
             key_list: KeyListResponse = self.key_list()
             api = key_api.KeyApi(api_client)
             request = KeySignRequest(
                 network_identifier=network_configuration.
                 network_identifier,
                 public_key=key_list.public_keys[0].public_key,
                 unsigned_transaction=unsigned_transaction)
             Helpers.print_request_body(request, "/key/sign")
             response = api.key_sign_post(request)
             return self.handle_response(response, print_response)
         except ApiException as e:
             Helpers.handleApiException(e)