Giter Club home page Giter Club logo

fiware-playground's Introduction

Criando um contexto com dados

Para rodar o FIWARE com docker-compose use:

git clone https://github.com/FIWARE/tutorials.Getting-Started.git
cd tutorials.Getting-Started
git checkout NGSI-v2

docker-compose -p fiware up -d

para mais detalhes da instalaçao, pode consultar o tutoral que pegamos o docker file ou visitar o site FIWARE para consultar a documentação.

Entidades

Nossas entidades serão SERVIÇOS ou API ou Microserviços ( ex.: payments, accounts, shopping...) Para listas as entidades que existem, podemos usar:

curl -iX GET 'http://localhost:1026/v2/entities'

Nesse momento você nao irá receber nenhuma entidade, ja que ainda nao cadastramos.

Vamos criar o primeiro microsserviço

curl -iX POST \
  'http://localhost:1026/v2/entities' \
  -H 'Content-Type: application/json' \
  -d '
{
    "id": "urn:ngsi-ld:microservice:001",
    "type": "microservice",
    "team": {
        "type": "team",
        "value": {
            "name": "Team Name Accounts",
            "email": "[email protected]"
        },
        "metadata": {
            "verified": {
                "value": true,
                "type": "Boolean"
            }
        }
    },
 
    "name": {
        "type": "Text",
        "value": "Accounts_Api"
    }
}'

Se voce realizar novamente o get na listagem de enteidades, voce ira ver o um elemento. Vamos cadastrar mais 2, Seguindo esse mesmo padrao.

Payments

curl -iX POST \
  'http://localhost:1026/v2/entities' \
  -H 'Content-Type: application/json' \
  -d '
{
    "id": "urn:ngsi-ld:microservice:002",
    "type": "microservice",
    "team": {
        "type": "team",
        "value": {
            "name": "Team Name Paymets",
            "email": "[email protected]"
        },
        "metadata": {
            "verified": {
                "value": true,
                "type": "Boolean"
            }
        }
    },
 
    "name": {
        "type": "Text",
        "value": "Paymets_Api"
    }
}'

shopping

curl -iX POST \
  'http://localhost:1026/v2/entities' \
  -H 'Content-Type: application/json' \
  -d '
{
    "id": "urn:ngsi-ld:microservice:003",
    "type": "microservice",
    "team": {
        "type": "team",
        "value": {
            "name": "Team Name shopping",
            "email": "[email protected]"
        },
        "metadata": {
            "verified": {
                "value": true,
                "type": "Boolean"
            }
        }
    },
 
    "name": {
        "type": "Text",
        "value": "shopping_api"
    }
}'

Agora se listar as entidades, teremos 3.

Busca de entidades

Conseguimos ver uma entidede usando o id dela, dessa forma:

curl -G -X GET \
   'http://localhost:1026/v2/entities/urn:ngsi-ld:microservice:001' \
   -d 'options=keyValues'

ou usando filtros

curl -G -X GET \
    'http://localhost:1026/v2/entities' \
    -d 'type=microservice' \
    -d 'options=keyValues'

Ou ainda com mais subparametros

curl -G -X GET \
    'http://localhost:1026/v2/entities' \
    -d 'type=microservice' \
    -d 'q=name~=_Api' \
    -d 'options=keyValues'

com o q=name~=_Api irá aparecer 2, ou o q=name~=_api irá aparecer 1. propositalmente, fiz o cadastro dessa forma para mostrar essa forma de filtrar.

Ou seja, existe diferenca entre maisuculo e minúsculo.

fiware-playground's People

Contributors

ramondomiingos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.