Commit 4e2d6358 authored by JorgeEcheva26's avatar JorgeEcheva26
Browse files

Only one aef available

parent f46ab93f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"


[project]
[project]
name = "opencapif_sdk"
name = "opencapif_sdk"
version = "0.1.8.2"
version = "0.1.8.4"
authors = [
authors = [
    { name="JorgeEcheva", email="jorge.echevarriauribarri.practicas@telefonica.com" },
    { name="JorgeEcheva", email="jorge.echevarriauribarri.practicas@telefonica.com" },
    { name="dgs-cgm", email="daniel.garciasanchez@telefonica.com" }
    { name="dgs-cgm", email="daniel.garciasanchez@telefonica.com" }
+62 −49
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@ import json
import logging
import logging
import os
import os
import re
import re
import yaml




log_path = 'logs/builder_logs.log'
log_path = 'logs/builder_logs.log'
@@ -60,14 +61,26 @@ class api_schema_translator:
        self.logger.info(f"API description saved to {api_name}.json")
        self.logger.info(f"API description saved to {api_name}.json")


    def __load_api_file(self, api_file: str):
    def __load_api_file(self, api_file: str):
        """Loads the configuration file."""
        """Loads the Swagger API configuration file and converts YAML to JSON format if necessary."""
        try:
        try:
            with open(api_file, 'r') as file:
            with open(api_file, 'r') as file:
                if api_file.endswith('.yaml') or api_file.endswith('.yml'):
                    yaml_content = yaml.safe_load(file)
                    return json.loads(json.dumps(yaml_content))  # Convert YAML to JSON format
                elif api_file.endswith('.json'):
                    return json.load(file)
                    return json.load(file)
                else:
                    self.logger.warning(
                        f"Unsupported file extension for {api_file}. Only .yaml, .yml, and .json are supported.")
                    return {}
        except FileNotFoundError:
        except FileNotFoundError:
            self.logger.warning(
            self.logger.warning(
                f"Configuration file {api_file} not found. Using defaults or environment variables.")
                f"Configuration file {api_file} not found. Using defaults or environment variables.")
            return {}
            return {}
        except (json.JSONDecodeError, yaml.YAMLError) as e:
            self.logger.error(
                f"Error parsing the configuration file {api_file}: {e}")
            return {}


    def __validate_api_info(self):
    def __validate_api_info(self):
        """Validates that all required components are present in the API specification."""
        """Validates that all required components are present in the API specification."""
@@ -81,8 +94,8 @@ class api_schema_translator:
        """Builds the aefProfiles section based on the paths and components in the API info."""
        """Builds the aefProfiles section based on the paths and components in the API info."""
        aef_profiles = []
        aef_profiles = []


        for path, methods in self.api_info.get("paths", {}).items():
        resources = []
        resources = []
        for path, methods in self.api_info.get("paths", {}).items():
            for method, details in methods.items():
            for method, details in methods.items():
                resource = {
                resource = {
                    "resourceName": details.get("summary", "Unnamed Resource"),
                    "resourceName": details.get("summary", "Unnamed Resource"),
@@ -96,7 +109,7 @@ class api_schema_translator:


        # Example profile creation based on paths, customize as needed
        # Example profile creation based on paths, customize as needed
        aef_profile = {
        aef_profile = {
                "aefId": "AEF07a01ccd74a160c195e69b4f116d66",  # Placeholder AEF ID
            "aefId": "",  # Placeholder AEF ID
            "versions": [
            "versions": [
                {
                {
                    "apiVersion": "v1",
                    "apiVersion": "v1",
+1 −1
Original line number Original line Diff line number Diff line
@@ -5,5 +5,5 @@ from setuptools import setup, find_packages
setup(
setup(
    name='opencapif_sdk',
    name='opencapif_sdk',
    packages=find_packages(include=["sdk"]),
    packages=find_packages(include=["sdk"]),
    version="0.1.8.2",
    version="0.1.8.4",
)
)
 No newline at end of file