Ver código fonte

FD3-222 PonPort RESTController

Guillermo Espinoza 7 anos atrás
pai
commit
06409d6671

+ 4 - 3
app/AppKernel.php

@@ -28,8 +28,8 @@ class AppKernel extends Kernel
             new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
             new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
 
-	        new MigrationsBundle\MigrationsBundle(),
-	        new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
+            new MigrationsBundle\MigrationsBundle(),
+            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
             
             new WebserviceBundle\WebserviceBundle(),
             new Base\AdminBundle\BaseAdminBundle(),
@@ -46,7 +46,8 @@ class AppKernel extends Kernel
             new GeoserverBundle\GeoserverBundle(),
             new LeafletBundle\LeafletBundle(),
             new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
-            new AuditBundle\AuditBundle()
+            new AuditBundle\AuditBundle(),
+            new AuthBundle\AuthBundle(),
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 1 - 0
app/config/config.yml

@@ -19,6 +19,7 @@ imports:
     - { resource: '@BaseAdminBundle/Resources/config/services.yml' }
     - { resource: '@GeoserverBundle/Resources/config/services.yml' }
     - { resource: "@AuditBundle/Resources/config/services.yml" }
+    - { resource: "@AuthBundle/Resources/config/services.yml" }
 
 # Put parameters here that don't need to change on each machine where the app is deployed
 # http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration

+ 5 - 0
app/config/routing.yml

@@ -1,3 +1,8 @@
+Stats_PonPort_api:
+        resource: "@StatsBundle/Controller/PonPortRESTController.php"
+        type:   rest
+        prefix:   /api
+
 stats:
     resource: "@StatsBundle/Controller/"
     type:     annotation

+ 9 - 1
app/config/security.yml

@@ -12,6 +12,13 @@ security:
         dev:
             pattern: ^/(_(profiler|wdt)|css|images|js)/
             security: false
+        
+        api:
+          pattern: ^/api
+          http_basic: true
+          stateless: true
+          oauth_proxy: true    
+            
         secured_area:
             pattern: ^/
             logout:
@@ -32,4 +39,5 @@ security:
                     
     access_control:
         - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
-        - { path: ^/admin/, role: ROLE_ADMIN }
+        - { path: ^/admin/, role: ROLE_ADMIN }
+        - { path: ^/api/, role: ROLE_USER }

+ 8 - 0
composer.json

@@ -114,6 +114,13 @@
             "options": {
                 "local_pk": "./keys/bitbucket.id_rsa"
             }
+        },
+        {
+            "type": "vcs",
+            "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/AuthBundle.git",
+            "options": {
+                "local_pk": "./keys/bitbucket.id_rsa"
+            }
         }
     ],
     "require": {
@@ -136,6 +143,7 @@
         "ik/stats/huawei-bundle": "dev-master",
         "ik/statsd-bundle": "dev-master",
         "ik/webservice-bundle": "dev-master",
+        "ik/auth-bundle": "dev-master",
         "incenteev/composer-parameter-handler": "^2.0",
         "jms/serializer-bundle": "^1.1",
         "opensolutions/oss-snmp": "dev-master",

+ 25 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "9741816d5a3c090e3fcf6f8f1ada5ece",
+    "content-hash": "9537de2fe076710e88c8f05bceddb60a",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1415,6 +1415,29 @@
             ],
             "time": "2017-06-27 13:16:34"
         },
+        {
+            "name": "ik/auth-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/AuthBundle.git",
+                "reference": "1ce5ec22c5e4cb5e043eff4ea9f5f6946dfc889d"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AuthBundle\\": ""
+                }
+            },
+            "description": "Flowdat 3 Auth Bundle",
+            "keywords": [
+                "Admin Generator",
+                "admin",
+                "auth",
+                "bundle"
+            ],
+            "time": "2017-09-21 14:36:31"
+        },
         {
             "name": "ik/base-admin-bundle",
             "version": "dev-master",
@@ -6161,6 +6184,7 @@
         "ik/stats/huawei-bundle": 20,
         "ik/statsd-bundle": 20,
         "ik/webservice-bundle": 20,
+        "ik/auth-bundle": 20,
         "opensolutions/oss-snmp": 20,
         "voryx/restgeneratorbundle": 20
     },

+ 32 - 0
src/StatsBundle/Controller/PonPortRESTController.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace StatsBundle\Controller;
+
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use StatsBundle\Form\PonPortType;
+use WebserviceBundle\Controller\RESTController;
+
+/**
+ * PonPort controller.
+ * @RouteResource("PonPort")
+ */
+class PonPortRESTController extends RESTController
+{
+
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'StatsBundle:PonPort';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new PonPortType());
+    }
+
+}

+ 1 - 5
src/StatsBundle/Entity/Onu.php

@@ -11,11 +11,10 @@ use Symfony\Component\Validator\Constraints as Assert;
  * @ORM\Entity
  * @UniqueEntity(fields={"deviceServer", "oltDeviceId", "ponSerialNumber"}, message="errors.duplicate_key")
  * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"device_server_id", "olt_device_id", "pon_serial_number"})})
- * 
  */
 class Onu
 {
-
+    
     /**
      * @var string
      *
@@ -29,14 +28,12 @@ class Onu
      *
      * @ORM\Id
      * @ORM\Column(type="integer", nullable=true)
-     * 
      */
     private $oltDeviceId;
 
     /**
      * @ORM\Id
      * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
-     * 
      */
     protected $deviceServer;
 
@@ -44,7 +41,6 @@ class Onu
      * @var int
      *
      * @ORM\Column(type="integer", nullable=true)
-     * 
      */
     private $deviceId;
 

+ 0 - 3
src/StatsBundle/Entity/PonPort.php

@@ -10,7 +10,6 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  * @ORM\Entity
  * @UniqueEntity(fields={"deviceServer", "oltDeviceId", "ponPort"}, message="errors.duplicate_key")
  * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"device_server_id", "olt_device_id", "pon_port"})})
- * 
  */
 class PonPort
 {
@@ -35,13 +34,11 @@ class PonPort
      * @var int
      *
      * @ORM\Column(type="integer", nullable=true)
-     * 
      */
     private $oltDeviceId;
 
     /**
      * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
-     * 
      */
     protected $deviceServer;
 

+ 38 - 0
src/StatsBundle/Form/PonPortType.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace StatsBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class PonPortType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('ponPort')->add('oltDeviceId')->add('tenancyId')->add('updated')->add('txPower')->add('rxPower')->add('voltage')->add('temperature')->add('biasCurrent')->add('deviceServer');
+    }
+    
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'StatsBundle\Entity\PonPort'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'statsbundle_ponport';
+    }
+
+
+}