Commit 6d7c3b80 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Fix endpoints to reach helper api

parent f7a83208
Loading
Loading
Loading
Loading
+36 −34
Original line number Diff line number Diff line
@@ -242,7 +242,7 @@ class Operations:


    def get_invokers(self):
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))


        try:
@@ -304,7 +304,7 @@ class Operations:
        

    def get_num_invokers(self):
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        
        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -325,7 +325,7 @@ class Operations:


    def get_invokers_pages_order1(self, page, page_size, sort_order):
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))

        # params = {
        #     'page': page,
@@ -343,7 +343,7 @@ class Operations:
            return jsonify({"error": str(e)}), 500

    def get_invokers_list(self):
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -357,14 +357,16 @@ class Operations:
            if invokers_list:
                return invokers_list  # Devolver solo los datos del invoker
            else:
                return {"error": "No list of invokers found"}
                # return jsonify({"error": "No list of invokers found"})
                return []  # Devolver una lista vacía si no se encuentra la lista de invokers


        except requests.exceptions.RequestException as e:
            print(f"Error: {str(e)}")  # Log de error
            return {"error": str(e)}
            return jsonify({"error": str(e)}), 500

    def get_invokers_pages_order(self, page, page_size, sort_order):
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -390,7 +392,7 @@ class Operations:
        
    def get_invoker_by_id(self, invoker_id):
        # Construir la URL con el invoker_id como query parameter
        url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        params = {"api_invoker_id": invoker_id}
        
        print(f"Requesting invoker with id: {invoker_id} to URL: {url}")  # Log simple
@@ -422,7 +424,7 @@ class Operations:
    
    def get_security_context_of_a_invoker(self, invoker_id):
        # Construir la URL con el invoker_id como query parameter
        url = "https://{}/helper/getSecurity".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getSecurity".format(os.getenv('CAPIF_HOSTNAME'))
        params = {"invoker_id": invoker_id}
        
        print(f"Requesting invoker with id: {invoker_id} to URL: {url}")  # Log simple
@@ -453,7 +455,7 @@ class Operations:
        
    def get_security_context_all(self):
        # Construir la URL con el invoker_id como query parameter
        url = "https://{}/helper/getSecurity".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getSecurity".format(os.getenv('CAPIF_HOSTNAME'))
        
        try:
            # Hacer la solicitud GET pasando el invoker_id como query parameter
@@ -476,7 +478,7 @@ class Operations:
    
    def get_invokers_of_a_user(self, uuid):
        # Construir la URL base
        base_url = "https://{}/helper/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        base_url = "https://{}/helper/api/getInvokers".format(os.getenv('CAPIF_HOSTNAME'))
        
        # Crear los parámetros de consulta (query parameters)
        query_params = {
@@ -516,7 +518,7 @@ class Operations:

        
    def get_providers(self):
        url = "https://{}/helper/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getProviders".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -535,7 +537,7 @@ class Operations:
            return jsonify({"error": str(e)}), 500

    def get_num_providers(self):
        url = "https://{}/helper/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        
        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -556,7 +558,7 @@ class Operations:
        

    def get_providers_list(self):
        url = "https://{}/helper/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getProviders".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -574,7 +576,7 @@ class Operations:
        
    def get_provider_by_id(self, api_prov_dom_id):
        # Construir la URL con el invoker_id como query parameter
        url = "https://{}/helper/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        params = {"api_prov_dom_id": api_prov_dom_id}
        
        print(f"Requesting provider with id: {api_prov_dom_id} to URL: {url}")  # Log simple
@@ -605,7 +607,7 @@ class Operations:
    
    def get_providers_of_a_user(self, uuid):
        # Construir la URL base
        base_url = "https://{}/helper/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        base_url = "https://{}/helper/api/getProviders".format(os.getenv('CAPIF_HOSTNAME'))
        
        # Crear los parámetros de consulta (query parameters)
        query_params = {
@@ -776,7 +778,7 @@ class Operations:

        
    def get_apis1(self):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -795,7 +797,7 @@ class Operations:
            return jsonify({"error": str(e)}), 500
    
    def get_apis(self):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -821,7 +823,7 @@ class Operations:
            

    def get_apis_list(self):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -838,7 +840,7 @@ class Operations:
            return jsonify({"error": str(e)}), 500

    def get_api_by_id(self, api_id):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        params = {"service_id": api_id}

        try:
@@ -857,7 +859,7 @@ class Operations:
            return {"error": str(e)}, 500  # D
        
    def get_apis_of_a_provider(self, apf_id):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        params = {"apf_id": apf_id}

        try:
@@ -877,7 +879,7 @@ class Operations:
   
    
    def get_num_apis(self):
        url = "https://{}/helper/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getServices".format(os.getenv('CAPIF_HOSTNAME'))
        
        try:
            response = requests.get(url, verify="newcerts/ca_root.crt", cert=("newcerts/superadmin.crt", "newcerts/superadmin.key"))
@@ -900,7 +902,7 @@ class Operations:
    
    def get_configuration(self):
        # Construimos la URL para la solicitud
        url = "https://{}/helper/getConfiguration".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/getConfiguration".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            # Realizamos la solicitud con los certificados y verificación del CA
@@ -928,7 +930,7 @@ class Operations:

    def update_configuration_param(self, param_path, new_value):
        """ Actualiza un único parámetro de la configuración """
        url = "https://{}/helper/updateConfigParam".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/updateConfigParam".format(os.getenv('CAPIF_HOSTNAME'))
        payload = {
            "param_path": param_path,
            "new_value": new_value
@@ -965,7 +967,7 @@ class Operations:

    def replace_configuration(self, new_config):
        """ Reemplaza toda la configuración con una nueva """
        url = "https://{}/helper/replaceConfiguration".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/replaceConfiguration".format(os.getenv('CAPIF_HOSTNAME'))

        try:
            response = requests.put(
@@ -983,7 +985,7 @@ class Operations:

    def add_new_category(self, category_name, category_values):
        """Añade una nueva categoría de parámetros en 'settings'."""
        url = "https://{}/helper/addNewConfiguration".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/addNewConfiguration".format(os.getenv('CAPIF_HOSTNAME'))
        payload = {
            "category_name": category_name,
            "category_values": category_values
@@ -1003,7 +1005,7 @@ class Operations:

    def add_new_config_setting(self, param_path, new_value):
        """Añade un nuevo parámetro en una categoría dentro de 'settings'."""
        url = "https://{}/helper/addNewConfigSetting".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/addNewConfigSetting".format(os.getenv('CAPIF_HOSTNAME'))
        payload = {
            "param_path": param_path,
            "new_value": new_value
@@ -1024,7 +1026,7 @@ class Operations:

    def remove_configuration_param(self, param_path):
        """ Elimina un parámetro dentro de una categoría en 'settings' """
        url = "https://{}/helper/removeConfigParam".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/removeConfigParam".format(os.getenv('CAPIF_HOSTNAME'))
        payload = {
            "param_path": param_path
        }
@@ -1044,7 +1046,7 @@ class Operations:

    def remove_configuration_category(self, category_name):
        """ Elimina una categoría completa dentro de 'settings' """
        url = "https://{}/helper/removeConfigCategory".format(os.getenv('CAPIF_HOSTNAME'))
        url = "https://{}/helper/api/removeConfigCategory".format(os.getenv('CAPIF_HOSTNAME'))
        payload = {
            "category_name": category_name
        }
+2 −2
Original line number Diff line number Diff line
@@ -28,5 +28,5 @@ services:
    
networks:
  default:
    external:
      name: capif-network
    name: ${CAPIF_NETWORK_NAME:-capif-network}
    external: true