GithubHelp home page GithubHelp logo

redhatinsights / topological_inventory-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 8.0 24.0 3.8 MB

License: Apache License 2.0

Dockerfile 0.62% Ruby 96.83% HTML 1.77% Shell 0.41% Groovy 0.38%
hacktoberfest

topological_inventory-api's Introduction

Topological Inventory API

Build Status Maintainability Test Coverage Security

This project exposes an API for accessing objects living in the Topological Inventory Service database

Prerequisites

You need to install ruby >= 2.2.2 and run:

bundle install

Getting started

This sample was generated with the swagger-codegen project.

bin/rake db:create db:migrate
bin/rails s

To list all your routes, use:

bin/rake routes

License

This project is available as open source under the terms of the Apache License 2.0.

topological_inventory-api's People

Contributors

abellotti avatar agrare avatar bdunne avatar bzwei avatar carbonin avatar eclarizio avatar fryguy avatar gmcculloug avatar gtanzillo avatar hyperkid123 avatar ladas avatar lindgrenj6 avatar lpichler avatar mkanoor avatar pkomanek avatar roliveri avatar slemrmartin avatar syncrou avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

topological_inventory-api's Issues

Set DATABASE_URL for all login shell sessions

Right now DATABASE_URL is only set in the entrypoint script.

This means that when you shell into a container to use the rails console you need to manually set the env variable to access anything.

We should move this to somewhere where it can be sourced from both situations.

openapi.json should not be authenticated

With the latest tenancy changes, /api/v0.1/openapi.json requires the x-rh-identity header, that path is unauthenticated in the Insights gateway, we should update the with_current_request method in application_controller.rb to allow for unauthenticated paths and let that puppy in.

Hot reload of models loses the as_json method

irb(main):001:0> SourceType.first.as_json(:prefixes => ["/v0.0/"])
  SourceType Load (0.5ms)  SELECT  "source_types".* FROM "source_types" ORDER BY "source_types"."id" ASC LIMIT $1  [["LIMIT", 1]]
=> {"id"=>"1", "name"=>"openshift", "product_name"=>"OpenShift", "vendor"=>"Red Hat"}
irb(main):002:0> reload!
Reloading...
=> true
irb(main):003:0> SourceType.first.as_json(:prefixes => ["/v0.0/"])
  SourceType Load (0.3ms)  SELECT  "source_types".* FROM "source_types" ORDER BY "source_types"."id" ASC LIMIT $1  [["LIMIT", 1]]
=> {"id"=>1, "name"=>"openshift", "product_name"=>"OpenShift", "vendor"=>"Red Hat", "created_at"=>Fri, 30 Nov 2018 16:01:42 UTC +00:00, "updated_at"=>Fri, 30 Nov 2018 16:01:42 UTC +00:00}

Update Travis links in READMEs files

Can't resolve './ID'

When trying to build API client from generated code i get following error:

ERROR in ./src/model/IDReadOnly.js
Module not found: Error: Can't resolve './ID' in '/home/mmarosi/service-portal/topological_inventory-api-jsclient-1/src/model'
 @ ./src/model/IDReadOnly.js 20:0-22 39:4-6 65:8-10 66:8-10
 @ ./src/model/Authentication.js
 @ ./src/index.js
error Command failed with exit code 2.

I am using API code gen and latest v0.1.0 schema. When i check the generated source code there is truly no ID.js file. Last successful client generation was from RedHatInsights/topological_inventory-api-jsclient@e61a221 (Feb 6).

When i was going through the API commits i think this might have something to do with it: 35196a7

cc @carbonin @bdunne

Offset is not allowed parameter

When trying to paginate at https://ci.foo.redhat.com:1337/r/insights/platform/topological-inventory/v0.1/sources/4/service_offerings?limit=2&offset=2

I get following error response:

{"errors":[{"status":"400","detail":"found unpermitted parameter: :offset in request parameters"}]}

Limit alone works fine, but offset does not. So i cant get anything but first page from collection.

cc @carbonin @bdunne

Inlined object being used for ordering service plans

https://github.com/ManageIQ/topological_inventory-api/blob/85cedfadc93dedb437112aa6cefb6e15fb07d709/public/doc/swagger-2-v0.0.1.yaml#L552

In the body section there are 2 free standing properties assigned to an inlined object.

We should move the 2 properties (service_parameters & provider_control_parameters) into a separate object definition and in the body just reference that object.

Also the parameter is a required field, you can't order a service without any parameters


"/service_plans/{id}/order":
    post:
      summary: Order an existing ServicePlan
.......

     - name: parameters
        in: body
        **required: true**
        description: Extra parameters defining the service and provider control
        schema:
             $ref: '#/definitions/OrderParameters'

.....
.....
definitions:
.....
OrderParameters:
    type: object
     properties:
         service_parameters:
              type: object
              description: JSON object with provisioning parameters
          provider_control_parameters:
              type: object
              description: >-
                The provider specific parameters needed to provision this service.
                This might include namespaces, special keys

Code generation issues

Due to the use of shared "parameters" in object "definitions" the code generator issues warnings

[main] WARN  o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref:#/parameters/ID. Default to 'object'
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/parameters/ID

and produces incorrect object definitions, anything that it cannot understand it converts to a object (hash)

For example the Flavor object has these simple string properties id, source_id,tenant_id

screen shot 2019-01-23 at 4 13 14 pm

The id, tenant_id and source_id should have been strings

This stems from the use of inheritance from parameters in definitions. The editor can show it but the code generator cannot handle it.

https://github.com/ManageIQ/topological_inventory-api/blob/59b3c6c65903cc10a38391cd1f633cf1f474c782/public/doc/swagger-2-v0.0.1.yaml#L1584

This applies to most of the object definitions where ID is being reused from parameter section.

Use common gem exception handling

As of #304 we are still doing manual rescue_from(exc) in ApplicationController, we should move the exceptions and their response code mappings to an initializer and let the common gem handle making the error document.

Refs

Paging links for pagination

Collections responses return correctly return links next, prev, first and last page. But those links are pointing towards something like this:

https://api-gateway-ci.5a9f.insights-dev.openshiftapps.com/r/insights/platform/topological-inventory/v0.1/sources/4/service_offerings?archived_at=&offset=0

That is not our API and we obviously don't have access to it. Yes i can compute the query params but i don't think that is something we want do in UI. We either get the part of after the API version (because we have our own base path which also defines API version ) or after /r or a object with query params (limit, offset, etc.).

We definitely don't want scheme or host address to be included in the pagination links, because it should be called through client APIs

cc @carbonin @bdunne

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.