# -*- coding: utf-8 -*-

# Copyright 2017 EMBL - European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from . import views
from django.conf.urls import url
from rest_framework.routers import DefaultRouter


app_name = "emgapi"
urlpatterns = [

    url(
        r'^runs/(?P<accession>[a-zA-Z0-9,_]+)/(?P<release_version>[0-9\.]+)$',
        views.RunAPIView.as_view(),
        name='runs-detail'
    ),

    # url(
    #     (r'^metadata/(?P<name>(.*)+)/(?P<value>(.*)+)$'),
    #     views.SampleAnnAPIView.as_view(),
    #     name='metadata-detail'
    # ),

]

router = DefaultRouter(trailing_slash=False)

router.register(
    r'studies',
    views.StudyViewSet,
    base_name='studies'
)

router.register(
    r'samples',
    views.SampleViewSet,
    base_name='samples'
)

router.register(
    r'runs',
    views.RunViewSet,
    base_name='runs'
)

router.register(
    r'pipelines',
    views.PipelineViewSet,
    base_name='pipelines'
)

router.register(
    r'experiments',
    views.ExperimentTypeViewSet,
    base_name='experiments'
)

router.register(
    r'biomes/(?P<lineage>[a-zA-Z0-9\:\-\s\(\)\<\>]+)',
    views.BiomeViewSet,
    base_name='biomes'
)

router.register(
    r'publications',
    views.PublicationViewSet,
    base_name='publications'
)

router.register(
    r'tools',
    views.PipelineToolViewSet,
    base_name='tools'
)

# router.register(
#     r'metadata',
#     views.SampleAnnsViewSet,
#     base_name='metadata'
# )


router.register(
    r'mydata',
    views.MyDataViewSet,
    base_name='mydata'
)

urlpatterns += router.urls

@@ -638,16 +638,18 @@
 t views%0A
+# 
 from dja
@@ -673,16 +673,16 @@
 ort url%0A
-
 from res
@@ -764,16 +764,60 @@
 = %5B%0A%0A   
+ # TODO: swagger override runs-details%0A    #
  url(%0A  
@@ -813,24 +813,26 @@
   # url(%0A   
+ #
      r'%5Eruns
@@ -899,20 +899,22 @@
 $',%0A    
+#
     
+ 
 views.Ru
@@ -936,16 +936,18 @@
 w(),%0A   
+ #
      nam
@@ -950,24 +950,34 @@
  name='runs-
+pipelines-
 detail'%0A    
@@ -975,16 +975,18 @@
 ail'%0A   
+ #
  ),%0A%0A   

remove runs-pipelines-details due to swagger