Commit 331e0ef6 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

update responses

parent 8cd00ac0
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -52,13 +52,13 @@ public class OSLMCPServerApplication {
  public record TextInput(String input) {
  }

  @Bean
  public ToolCallback toUpperCase() {
      return FunctionToolCallback.builder("toUpperCase", (TextInput input) -> input.input().toUpperCase())
          .inputType(TextInput.class)
          .description("Put the text to upper case")
          .build();
  }
//  @Bean
//  public ToolCallback toUpperCase() {
//      return FunctionToolCallback.builder("toUpperCase", (TextInput input) -> input.input().toUpperCase())
//          .inputType(TextInput.class)
//          .description("Put the text to upper case")
//          .build();
//  }
  
  @Bean
  public List<McpServerFeatures.SyncResourceSpecification> myResources() {
+107 −16
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.etsi.osl.tmf.common.model.Any;
import org.etsi.osl.tmf.common.model.service.Characteristic;
import org.etsi.osl.tmf.common.model.service.Note;
@@ -46,66 +48,146 @@ public class ProductCatalogTools {
  
  @Tool(description = "Get a list of all published OSL OpenSlice product catalogs."
      + "Each catalog contains product categories, that we can search individually to get the details and contents of each category.")
  public List<Catalog> getOSLProductCatalogs() {
  public JsonNode getOSLProductCatalogs() {

    logger.info("getOSLProductCatalogs");
    List<Catalog> serviceCatalogs = aCatalogClient.retrieveProductCatalogs();
    
    
 
    return serviceCatalogs;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "@type"};
      JsonNode filtered = JsonMassage.filterJsonByTokens( serviceCatalogs, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( serviceCatalogs );
    return rootNode;
  }
  
  @Tool(description = "Get OSL product categories in product catalog providing a catalog name")
  public List<Category> getOSLProductCategories(String catalogName) {
  public JsonNode getOSLProductCategories(String catalogName) {
    
    logger.info("getOSLProductCategories {}", catalogName);

    List<Category> productCategories = aCatalogClient.retrieveProductCategoriesDetailsOfCatalog(catalogName);
    
    return productCategories;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "@type"};
      JsonNode filtered = JsonMassage.filterJsonByTokens( productCategories, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( productCategories );
    return rootNode;
  }

  
  @Tool(description = "Get a list of OSL product offerings in a product category, given a category ID")
  public List<ProductOffering> getOSLProductOfferingsInCategory(String categoryId) {
  public JsonNode getOSLProductOfferingsInCategory(String categoryId) {
    
    logger.info("getOSLProductOfferingsInCategory {}", categoryId);
    List<ProductOffering> productCategories = aCatalogClient.retrieveProductOfferingsByCategoryId(categoryId);
    return productCategories;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description"};
      JsonNode filtered = JsonMassage.filterJsonByTokens( productCategories, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( productCategories );
    return rootNode;
  
    
  }
  
  @Tool(description = "Get all the details of an OSL product offering give a product offering Id")
  public ProductOffering getOSLProductOfferingByProductOfferingId(String productOfferingId) {
  public JsonNode getOSLProductOfferingByProductOfferingId(String productOfferingId) {
    
    logger.info("getOSLProductOfferingByProductOfferingId {}", productOfferingId);

    ProductOffering spec =  aCatalogClient.retrieveProductOffering(productOfferingId);

    return spec;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "isBundle", "@type", "configurable", "valueType", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
    
  }
  
  @Tool(description = "Get all the details of an OSL product specification give a product Specification Id")
  public ProductSpecification getOSLProductByProductSpecificationId(String productSpecId) {
  public JsonNode getOSLProductByProductSpecificationId(String productSpecId) {
    
    logger.info("getOSLProductByProductSpecificationId {}", productSpecId);

    ProductSpecification spec =  aCatalogClient.retrieveProductSpec(productSpecId);

    return spec;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "isBundle", "@type", "configurable", "valueType", "isBundle", 
          "productNumber", "brand", "isBundle", "isBundle", "isBundle", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
  }
  

  @Tool(description = "Search for OSL product Offerings that are published and available for product ordering in all categories")
  public List<String> searchOSLProductOfferings( List<String> searchStrings) {
  public JsonNode searchOSLProductOfferings( List<String> searchStrings) {
    
    logger.info("searchOSLProductOfferings containing workds: {}", searchStrings);

    List<String> spec =  aCatalogClient.searchProductOfferings( searchStrings );

    return spec;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "isBundle", "@type", "configurable", "valueType", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
  }
  
  @Tool(description = "Create a product order given a Product Offering id, the Start date an end date of the order. "
@@ -188,16 +270,25 @@ public class ProductCatalogTools {
      + "- the state of the product order"
      + "- and each order item. Especially for each order item focus to the product and especially: status, characteristics and supporting products."
      + "- For each supporting product we can retrieve more information by using the product id.")
  public String getProductOrder(String productOrderId) {
  public JsonNode getProductOrder(String productOrderId) {
    
    logger.info("productOrderId {} {} {} {}", productOrderId);
    ProductOrder so = aCatalogClient.retrieveProductOrder(productOrderId);
    // Filter and get result as JSON string
    try {
      return ServiceCatalogQClient.toJsonString(so);
    } catch (IOException e) {

      String[] tokens = {"id", "name", "description",  "orderDate", "completionDate",
          "expectedCompletionDate", "requestedCompletionDate" , "requestedStartDate" , "startDate" , "category" , "state" , "action" , "value"   };
      JsonNode filtered = JsonMassage.filterJsonByTokens( so, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( so );
    return rootNode;
  }


+107 −23
Original line number Diff line number Diff line
@@ -105,50 +105,103 @@ public class ServiceCatalogTools {

  
  @Tool(description = "Get a list of OSL service specification references in a service category, given a category ID")
  public List<ServiceSpecificationRef> getOSLServiceSpecsInCategory(String categoryId) {
  public JsonNode getOSLServiceSpecsInCategory(String categoryId) {
    
    logger.info("getOSLServiceSpecsInCategory {}", categoryId);
    

    List<ServiceSpecificationRef> serviceCategories = aCatalogClient.retrieveServiceSpecsByCategoryId(categoryId);

    return serviceCategories;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description"};
      JsonNode filtered = JsonMassage.filterJsonByTokens( serviceCategories, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( serviceCategories );
    return rootNode;
    
    
  
    
  }
  
  @Tool(description = "Get all the details of an OSL service specification given a service Specification Id")
  public ServiceSpecification getOSLServiceSpecificationByServiceSpecificationId(String serviceSpecId) {
  public JsonNode getOSLServiceSpecificationByServiceSpecificationId(String serviceSpecId) {
    
    logger.info("getOSLServiceByServiceSpecificationId {}", serviceSpecId);

    ServiceSpecification spec =  aCatalogClient.retrieveServiceSpec(serviceSpecId);

    return spec;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "isBundle", "@type", "configurable", "valueType", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
  }
  
  
  
  @Tool(description = "Get all the details of an OSL resource specification given a resource Specification Id")
  public LogicalResourceSpecification getOSLResourceSpecificationByResourceSpecificationId(String resourceSpecId) {
  public JsonNode getOSLResourceSpecificationByResourceSpecificationId(String resourceSpecId) {
    
    logger.info("getOSLResourceSpecificationByResourceSpecificationId {}", resourceSpecId);

    LogicalResourceSpecification spec =  aCatalogClient.retrieveResourceSpec(resourceSpecId);
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "@type", "configurable", "valueType", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    return spec;
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
  }
  
  

  @Tool(description = "Search for OSL service specifications that are published and available for service ordering in all categories")
  public List<String> searchOSLServiceSpecifications( List<String> searchStrings) {
  public JsonNode searchOSLServiceSpecifications( List<String> searchStrings) {
    
    logger.info("searchOSLServiceSpecifications containing words: {}", searchStrings);

    List<String> spec =  aCatalogClient.searchServiceSpecs( searchStrings );

    return spec;
    // Filter and get result as JSON string
    try {

      String[] tokens = {"id", "name", "description", "@type", "configurable", "valueType", "isBundle" };
      JsonNode filtered = JsonMassage.filterJsonByTokens( spec, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( spec );
    return rootNode;
  }
  
  @Tool(description = "Create a service order given a Service Specification id, the Start date an end date of the order. "
@@ -238,43 +291,74 @@ public class ServiceCatalogTools {
      + "- the state of the service order"
      + "- and each order item. Especially for each order item focus to the service and especially: status, characteristics and supporting services."
      + "- For each supporting service we can retrieve more information by using the service id.")
  public String getServiceOrder(String serviceOrderId) {
  public JsonNode getServiceOrder(String serviceOrderId) {
    
    logger.info("serviceOrderId {} {} {} {}", serviceOrderId);
    ServiceOrder so = aCatalogClient.retrieveServiceOrder(serviceOrderId);
      
      // Filter and get result as JSON string
      try {
      return ServiceCatalogQClient.toJsonString(so);
    } catch (IOException e) {

        String[] tokens = {"id", "name", "description",  "orderDate", "completionDate",
            "expectedCompletionDate", "requestedCompletionDate" , "requestedStartDate" , "startDate" , "category" , "state" , "action" , "value"   };
        JsonNode filtered = JsonMassage.filterJsonByTokens( so, tokens);
        return filtered;
      } catch (Exception e) {
        e.printStackTrace();
      }
    return "";
    
      ObjectMapper mapper = new ObjectMapper();
      //return mapper.writeValueAsString(serviceCatalogs);
      JsonNode rootNode = mapper.valueToTree( so );
      return rootNode;
      
    
  }

  @Tool(description = "Provide details for a service  given a Service id. Especially for name, state, characteristics, supporting Services and supporting Resources."
      + "We can get details for each supporting service using the service id."
      + "and for each supporting resource using the resource id.")
  public String getService(String serviceId) {
  public JsonNode getService(String serviceId) {
    logger.info("getService {} {} {} {}", serviceId);
    Service s = aCatalogClient.retrieveService(serviceId);
    // Filter and get result as JSON string
    try {
      return ServiceCatalogQClient.toJsonString(s);
    } catch (IOException e) {

      String[] tokens = {"id", "name", "description", 
          "category" , "serviceDate" , "serviceType" , "state" , "value"  };
      JsonNode filtered = JsonMassage.filterJsonByTokens( s, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( s );
    return rootNode;
    
  }

  @Tool(description = "Provide details for a resource  given a Resourceid. Especially for name, status, characteristics."
      + "We can get details for each supporting resource using the resource id.")
  public String getResource(String resourceId) {
  public JsonNode getResource(String resourceId) {
    logger.info("getResource {} {} {} {}", resourceId);
    Resource r = aCatalogClient.retrieveResource ( resourceId);
    // Filter and get result as JSON string
    try {
      return ServiceCatalogQClient.toJsonString(r);
    } catch (IOException e) {

      String[] tokens = {"id", "name", "description", "startOperatingDate", "endOperatingDate", 
          "category" , "resourceStatus" , "state" , "value" , "valueType"  };
      JsonNode filtered = JsonMassage.filterJsonByTokens( r, tokens);
      return filtered;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "";
  
    ObjectMapper mapper = new ObjectMapper();
    //return mapper.writeValueAsString(serviceCatalogs);
    JsonNode rootNode = mapper.valueToTree( r );
    return rootNode;
  }