<commit_before>require 'sinatra'
require 'json'

$functions = [{
    'uuid'=> "0f4eb013-28b1-4590-b59d-d3f094e168d8",
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s,
    "vnf_id"=>"vnf_firewall",
    "vendor"=>"eu.sonata-nfv", 
    "name"=>"firewall-vnf", 
    "version"=>"0.1"
  }]
$packages = [
  {
    "uuid"=> "53676529-b277-4369-8ff9-8668310eab7d", 
    "descriptor_version"=>"1.0",
    "group"=>"eu.sonata-nfv.package",
    "name"=>"sonata-demo",
    "version"=>"0.1.1",
    "maintainer"=>"<NAME>, NEC Labs Europe",
    "description"=>"\"The package descriptor for the SONATA demo package that\n comprises the descritors of the demo network service,\n the related VNFs, as well as the virtual machine\n images (or docker files) to instantiate the service.\"\n", "entry_service_template"=>"/service_descriptors/sonata-demo.yml",
    "sealed"=>true,
    "package_content"=>[
      {"name"=>"/service_descriptors/sonata-demo.yml", "content-type"=>"application/sonata.service_descriptor", "md5"=>"a16ce1b66bd6d6916c8f994efca0d778" },
      {"name"=>"/function_descriptors/iperf-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"f70587f5f8cbdb60d79a4446a993c8de"},
      {"name"=>"/function_descriptors/firewall-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"d6c6fc264c5278fb1ccccaa6bdc4e64a"},
      {"name"=>"/function_descriptors/tcpdump-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"ef085df7c17eb65e25dbe0979de06920"},
      {"name"=>"/docker_files/iperf/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"5bea7b1f2f73803946674adecaaa9246"},
      {"name"=>"/docker_files/firewall/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"fed89e35d173e6aeaf313e1a9ab3f552"},
      {"name"=>"/docker_files/tcpdump/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"e0d2bb965744161ffb0f8af459a589e3"}
    ],
    "artifact_dependencies"=>[
      {
        "name"=>"my-vm-image",
        "url"=>"http://www.bredel-it.de/path/to/vm-image",
        "md5"=>"00236a2ae558018ed13b5222ef1bd9f3",
        "credentials"=>{"username"=>"username", "password"=>"password"}
      }
    ],
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s
  },
  { 
    'uuid'=> "0f4eb013-28b1-4590-b59d-d3f094e168d8", 
    "descriptor_version"=>"1.0",
    "vendor"=>"eu.sonata-nfv.package",
    "name"=>"sonata-demo",
    "version"=>"0.1.2",
    "maintainer"=>"<NAME>, NEC Labs Europe",
    "description"=>"\"The package descriptor for the SONATA demo package that\n comprises the descritors of the demo network service,\n the related VNFs, as well as the virtual machine\n images (or docker files) to instantiate the service.\"\n", "entry_service_template"=>"/service_descriptors/sonata-demo.yml",
    "sealed"=>true,
    "package_content"=>[
      {"name"=>"/service_descriptors/sonata-demo.yml", "content-type"=>"application/sonata.service_descriptor", "md5"=>"a16ce1b66bd6d6916c8f994efca0d778" },
      {"name"=>"/function_descriptors/iperf-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"f70587f5f8cbdb60d79a4446a993c8de"},
      {"name"=>"/function_descriptors/firewall-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"d6c6fc264c5278fb1ccccaa6bdc4e64a"},
      {"name"=>"/function_descriptors/tcpdump-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"ef085df7c17eb65e25dbe0979de06920"},
      {"name"=>"/docker_files/iperf/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"5bea7b1f2f73803946674adecaaa9246"},
      {"name"=>"/docker_files/firewall/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"fed89e35d173e6aeaf313e1a9ab3f552"},
      {"name"=>"/docker_files/tcpdump/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"e0d2bb965744161ffb0f8af459a589e3"}
    ],
    "artifact_dependencies"=>[
      {
        "name"=>"my-vm-image",
        "url"=>"http://www.bredel-it.de/path/to/vm-image",
        "md5"=>"00236a2ae558018ed13b5222ef1bd9f3",
        "credentials"=>{"username"=>"username", "password"=>"password"}
      }
    ],
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s
  }
]
$services = [
  {
    "descriptor_version"=>"1.0", 
    "vendor"=>"eu.sonata-nfv.service-descriptor", 
    "name"=>"sonata-demo", 
    "version"=>"0.1", 
    "author"=>"Sonata, sonata-nfv", 
    "description"=>"\"The network service descriptor for the SONATA demo,\n comprising iperf, a firewall, and tcpump.\"\n", 
    "network_functions"=>[{
      "vnf_id"=>"vnf_firewall",
      "vendor"=>"eu.sonata-nfv", 
      "name"=>"firewall-vnf", 
      "version"=>"0.1"
    }],
    "connection_points"=>[
      {"id"=>"ns:mgmt", "type"=>"interface"}, 
      {"id"=>"ns:input", "type"=>"interface"}, 
      {"id"=>"ns:output", "type"=>"interface"}
    ], 
    "virtual_links"=>[
      {"id"=>"mgmt", "connectivity_type"=>"E-LAN", "connection_points_reference"=>["vnf_firewall:mgmt", "ns:mgmt"]}, 
      {"id"=>"input", "connectivity_type"=>"E-Line", "connection_points_reference"=>["vnf_firewall:input", "ns:input"]}, 
      {"id"=>"output", "connectivity_type"=>"E-Line", "connection_points_reference"=>["vnf_firewall:output", "ns:output"]}
    ], 
    "forwarding_graphs"=>[
      {
        "fg_id"=>"ns:fg01", 
        "number_of_endpoints"=>2, 
        "number_of_virtual_links"=>2, 
        "constituent_vnfs"=>["vnf_firewall"], 
        "network_forwarding_paths"=>[
          {"fp_id"=>"ns:fg01:fp01", "policy"=>"none", "connection_points"=>[
            {"connection_point_ref"=>"ns:input", "position"=>1}, 
            {"connection_point_ref"=>"vnf_firewall:input", "position"=>2}, 
            {"connection_point_ref"=>"vnf_firewall:output", "position"=>3}, 
            {"connection_point_ref"=>"ns:output", "position"=>4}
          ]}
        ]
      }],
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s,
    'uuid'=> "0f4eb013-28b1-4590-b59d-d3f094e168d8"
  }
]

get '/catalogues/packages/:uuid' do
  content_type :json
  puts params.inspect
  $packages.each do |p|
    puts p.inspect
    return p.to_json if params['uuid'] == p['uuid']
  end
  {}.to_json
end

get '/catalogues/packages' do
  content_type :json
  ['offset', 'limit'].each do |p|<commit_msg>A little tweak in the fake Catalogues<commit_after>require 'sinatra'
require 'json'

$functions = [{
    'uuid'=> "0f4eb013-28b1-4590-b59d-d3f094e168d8",
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s,
    "vnf_id"=>"vnf_firewall",
    "vendor"=>"eu.sonata-nfv", 
    "name"=>"firewall-vnf", 
    "version"=>"0.1"
  }]
$packages = [
  {
    "uuid"=> "53676529-b277-4369-8ff9-8668310eab7d", 
    "descriptor_version"=>"1.0",
    "group"=>"eu.sonata-nfv.package",
    "name"=>"sonata-demo",
    "version"=>"0.1.1",
    "maintainer"=>"<NAME>, NEC Labs Europe",
    "description"=>"\"The package descriptor for the SONATA demo package that\n comprises the descritors of the demo network service,\n the related VNFs, as well as the virtual machine\n images (or docker files) to instantiate the service.\"\n", "entry_service_template"=>"/service_descriptors/sonata-demo.yml",
    "sealed"=>true,
    "package_content"=>[
      {"name"=>"/service_descriptors/sonata-demo.yml", "content-type"=>"application/sonata.service_descriptor", "md5"=>"a16ce1b66bd6d6916c8f994efca0d778" },
      {"name"=>"/function_descriptors/iperf-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"f70587f5f8cbdb60d79a4446a993c8de"},
      {"name"=>"/function_descriptors/firewall-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"d6c6fc264c5278fb1ccccaa6bdc4e64a"},
      {"name"=>"/function_descriptors/tcpdump-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"ef085df7c17eb65e25dbe0979de06920"},
      {"name"=>"/docker_files/iperf/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"5bea7b1f2f73803946674adecaaa9246"},
      {"name"=>"/docker_files/firewall/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"fed89e35d173e6aeaf313e1a9ab3f552"},
      {"name"=>"/docker_files/tcpdump/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"e0d2bb965744161ffb0f8af459a589e3"}
    ],
    "artifact_dependencies"=>[
      {
        "name"=>"my-vm-image",
        "url"=>"http://www.bredel-it.de/path/to/vm-image",
        "md5"=>"00236a2ae558018ed13b5222ef1bd9f3",
        "credentials"=>{"username"=>"username", "password"=>"password"}
      }
    ],
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s
  },
  { 
    'uuid'=> "0f4eb013-28b1-4590-b59d-d3f094e168d8", 
    "descriptor_version"=>"1.0",
    "vendor"=>"eu.sonata-nfv.package",
    "name"=>"sonata-demo",
    "version"=>"0.1.2",
    "maintainer"=>"<NAME>, NEC Labs Europe",
    "description"=>"\"The package descriptor for the SONATA demo package that\n comprises the descritors of the demo network service,\n the related VNFs, as well as the virtual machine\n images (or docker files) to instantiate the service.\"\n", "entry_service_template"=>"/service_descriptors/sonata-demo.yml",
    "sealed"=>true,
    "package_content"=>[
      {"name"=>"/service_descriptors/sonata-demo.yml", "content-type"=>"application/sonata.service_descriptor", "md5"=>"a16ce1b66bd6d6916c8f994efca0d778" },
      {"name"=>"/function_descriptors/iperf-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"f70587f5f8cbdb60d79a4446a993c8de"},
      {"name"=>"/function_descriptors/firewall-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"d6c6fc264c5278fb1ccccaa6bdc4e64a"},
      {"name"=>"/function_descriptors/tcpdump-vnfd.yml", "content-type"=>"application/sonata.function_descriptor", "md5"=>"ef085df7c17eb65e25dbe0979de06920"},
      {"name"=>"/docker_files/iperf/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"5bea7b1f2f73803946674adecaaa9246"},
      {"name"=>"/docker_files/firewall/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"fed89e35d173e6aeaf313e1a9ab3f552"},
      {"name"=>"/docker_files/tcpdump/Dockerfile", "content-type"=>"application/sonata.docker_files", "md5"=>"e0d2bb965744161ffb0f8af459a589e3"}
    ],
    "artifact_dependencies"=>[
      {
        "name"=>"my-vm-image",
        "url"=>"http://www.bredel-it.de/path/to/vm-image",
        "md5"=>"00236a2ae558018ed13b5222ef1bd9f3",
        "credentials"=>{"username"=>"username", "password"=>"password"}
      }
    ],
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s
  }
]
$services = [
  {
    "descriptor_version"=>"1.0", 
    "vendor"=>"eu.sonata-nfv.service-descriptor", 
    "name"=>"sonata-demo", 
    "version"=>"0.1", 
    "author"=>"Sonata, sonata-nfv", 
    "description"=>"\"The network service descriptor for the SONATA demo,\n comprising iperf, a firewall, and tcpump.\"\n", 
    "network_functions"=>[{
      "vnf_id"=>"vnf_firewall",
      "vendor"=>"eu.sonata-nfv", 
      "name"=>"firewall-vnf", 
      "version"=>"0.1"
    }],
    "connection_points"=>[
      {"id"=>"ns:mgmt", "type"=>"interface"}, 
      {"id"=>"ns:input", "type"=>"interface"}, 
      {"id"=>"ns:output", "type"=>"interface"}
    ], 
    "virtual_links"=>[
      {"id"=>"mgmt", "connectivity_type"=>"E-LAN", "connection_points_reference"=>["vnf_firewall:mgmt", "ns:mgmt"]}, 
      {"id"=>"input", "connectivity_type"=>"E-Line", "connection_points_reference"=>["vnf_firewall:input", "ns:input"]}, 
      {"id"=>"output", "connectivity_type"=>"E-Line", "connection_points_reference"=>["vnf_firewall:output", "ns:output"]}
    ], 
    "forwarding_graphs"=>[
      {
        "fg_id"=>"ns:fg01", 
        "number_of_endpoints"=>2, 
        "number_of_virtual_links"=>2, 
        "constituent_vnfs"=>["vnf_firewall"], 
        "network_forwarding_paths"=>[
          {"fp_id"=>"ns:fg01:fp01", "policy"=>"none", "connection_points"=>[
            {"connection_point_ref"=>"ns:input", "position"=>1}, 
            {"connection_point_ref"=>"vnf_firewall:input", "position"=>2}, 
            {"connection_point_ref"=>"vnf_firewall:output", "position"=>3}, 
            {"connection_point_ref"=>"ns:output", "position"=>4}
          ]}
        ]
      }],
    'status'=> 'OK',
    'created_at'=> Time.now.utc.to_s,
    'updated_at'=> Time.now.utc.to_s,
    'uuid'=> "15eb8a1c-ebf4-4d6d-878c-c4a55cfadb7e"
  }
]

get '/catalogues/packages/:uuid' do
  content_type :json
  puts params.inspect
  $packages.each do |p|
    puts p.inspect
    return p.to_json if params['uuid'] == p['uuid']
  end
  {}.to_json
end

get '/catalogues/packages' do
  content_type :json
  ['offset', 'limit'].each do |p|
{'fraction_non_alphanumeric': 0.20179858903790993, 'fraction_numerical': 0.06620668268858051, 'mean_word_length': 4.548387096774194, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 278, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112176', 'n_tokens_mistral': 5589, 'n_tokens_neox': 5064, 'n_words': 547}