/
requests.py
1000 lines (960 loc) · 41 KB
/
requests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# 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.
import json
import flask
from flask import Flask, Response
from typing import TYPE_CHECKING
from rucio.api import request
from rucio.common.exception import RequestNotFound
from rucio.common.utils import APIEncoder, render_json
from rucio.core.rse import get_rses_with_attribute_value
from rucio.db.sqla.constants import RequestState
from rucio.web.rest.flaskapi.authenticated_bp import AuthenticatedBlueprint
from rucio.web.rest.flaskapi.v1.common import check_accept_header_wrapper_flask, parse_scope_name, try_stream, \
response_headers, generate_http_error_flask, ErrorHandlingMethodView
if TYPE_CHECKING:
from typing import Iterator
class RequestGet(ErrorHandlingMethodView):
""" REST API to get requests. """
@check_accept_header_wrapper_flask(['application/json'])
def get(self, scope_name, rse):
"""
---
summary: Get Request
description: Get a request for a given DID to a destinaion RSE.
tags:
- Requests
parameters:
- name: scope_name
in: path
description: Data identifier (scope)/(name).
schema:
type: string
style: simple
- name: rse
in: path
description: Destination rse.
schema:
type: string
style: simple
responses:
200:
description: OK
content:
application/json:
schema:
description: The request associated with the DID and destination RSE.
type: object
properties:
id:
description: The id of the request.
type: string
request_type:
description: The request type.
type: string
enum: ["T", "U", "D", "I", "O"]
scope:
description: The scope of the transfer.
type: string
name:
description: The name of the transfer.
type: string
did_type:
description: The did type.
type: string
dest_rse_id:
description: The destination RSE id.
type: string
source_rse_id:
description: The source RSE id.
type: string
attributes:
description: All attributes associated with the request.
type: string
state:
description: The state of the request.
type: string
enum: ["Q", "G", "S", "F", "D", "L", "N", "O", "A", "M", "U", "W", "P"]
external_id:
description: External id of the request.
type: string
external_host:
description: External host of the request.
type: string
retry_count:
description: The numbers of attempted retires.
type: integer
err_msg:
description: An error message if one occured.
type: string
previous_attempt_id:
description: The id of the previous attempt.
type: string
rule_id:
description: The id of the associated replication rule.
type: string
activity:
description: The activity of the request.
type: string
bytes:
description: The size of the did in bytes.
type: integer
md5:
description: The md5 checksum of the did to transfer.
type: string
adler32:
description: The adler32 checksum of the did to transfer.
type: string
dest_url:
description: The destination url.
type: string
submitted_at:
description: The time the request got submitted.
type: string
started_at:
description: The time the request got started.
type: string
transferred_at:
description: The time the request got transfered.
type: string
estimated_at:
description: The time the request got estimated.
type: string
submitter_id:
description: The id of the submitter.
type: string
estimated_stated_at:
description: The estimation of the started at value.
type: string
estimated_transferred_at:
description: The estimation of the transfered at value.
type: string
staging_started_at:
description: The time the staging got started.
type: string
staging_finished_at:
description: The time the staging got finished.
type: string
account:
description: The account which issued the request.
type: string
requested_at:
description: The time the request got requested.
type: string
priority:
description: The priority of the request.
type: integer
transfertool:
description: The transfertool used.
type: string
source_rse:
description: The name of the source RSE.
type: string
dest_rse:
description: The name of the destination RSE.
type: string
401:
description: Invalid Auth Token
404:
description: Not found
406:
description: Not acceptable
"""
try:
scope, name = parse_scope_name(scope_name, flask.request.environ.get('vo'))
except ValueError as error:
return generate_http_error_flask(400, error)
try:
request_data = request.get_request_by_did(
scope=scope,
name=name,
rse=rse,
issuer=flask.request.environ.get('issuer'),
vo=flask.request.environ.get('vo'),
)
return Response(json.dumps(request_data, cls=APIEncoder), content_type='application/json')
except RequestNotFound as error:
return generate_http_error_flask(404, error.__class__.__name__, f'No request found for DID {scope}:{name} at RSE {rse}')
class RequestHistoryGet(ErrorHandlingMethodView):
""" REST API to get historical requests. """
@check_accept_header_wrapper_flask(['application/json'])
def get(self, scope_name, rse):
"""
---
summary: Get Historical Request
description: List a hostorical request for a given DID to a destination RSE.
tags:
- Requests
parameters:
- name: scope_name
in: path
description: Data identifier (scope)/(name).
schema:
type: string
style: simple
- name: rse
in: path
description: Destination rse.
schema:
type: string
style: simple
responses:
200:
description: OK
content:
application/json:
schema:
description: The request associated with the DID and destination RSE.
type: object
properties:
id:
description: The id of the request.
type: string
request_type:
description: The request type.
type: string
enum: ["T", "U", "D", "I", "O"]
scope:
description: The scope of the transfer.
type: string
name:
description: The name of the transfer.
type: string
did_type:
description: The did type.
type: string
dest_rse_id:
description: The destination RSE id.
type: string
source_rse_id:
description: The source RSE id.
type: string
attributes:
description: All attributes associated with the request.
type: string
state:
description: The state of the request.
type: string
enum: ["Q", "G", "S", "F", "D", "L", "N", "O", "A", "M", "U", "W", "P"]
external_id:
description: External id of the request.
type: string
external_host:
description: External host of the request.
type: string
retry_count:
description: The numbers of attempted retires.
type: integer
err_msg:
description: An error message if one occured.
type: string
previous_attempt_id:
description: The id of the previous attempt.
type: string
rule_id:
description: The id of the associated replication rule.
type: string
activity:
description: The activity of the request.
type: string
bytes:
description: The size of the did in bytes.
type: integer
md5:
description: The md5 checksum of the did to transfer.
type: string
adler32:
description: The adler32 checksum of the did to transfer.
type: string
dest_url:
description: The destination url.
type: string
submitted_at:
description: The time the request got submitted.
type: string
started_at:
description: The time the request got started.
type: string
transferred_at:
description: The time the request got transfered.
type: string
estimated_at:
description: The time the request got estimated.
type: string
submitter_id:
description: The id of the submitter.
type: string
estimated_stated_at:
description: The estimation of the started at value.
type: string
estimated_transferred_at:
description: The estimation of the transfered at value.
type: string
staging_started_at:
description: The time the staging got started.
type: string
staging_finished_at:
description: The time the staging got finished.
type: string
account:
description: The account which issued the request.
type: string
requested_at:
description: The time the request got requested.
type: string
priority:
description: The priority of the request.
type: integer
transfertool:
description: The transfertool used.
type: string
source_rse:
description: The name of the source RSE.
type: string
dest_rse:
description: The name of the destination RSE.
type: string
401:
description: Invalid Auth Token
404:
description: Not found
406:
description: Not acceptable
"""
try:
scope, name = parse_scope_name(scope_name, flask.request.environ.get('vo'))
except ValueError as error:
return generate_http_error_flask(400, error)
try:
request_data = request.get_request_history_by_did(
scope=scope,
name=name,
rse=rse,
issuer=flask.request.environ.get('issuer'),
vo=flask.request.environ.get('vo'),
)
return Response(json.dumps(request_data, cls=APIEncoder), content_type='application/json')
except RequestNotFound as error:
return generate_http_error_flask(404, error.__class__.__name__, f'No request found for DID {scope}:{name} at RSE {rse}')
class RequestList(ErrorHandlingMethodView):
""" REST API to get requests. """
@check_accept_header_wrapper_flask(['application/x-json-stream'])
def get(self):
"""
---
summary: List Requests
description: List requests for a given source and destination RSE or site.
tags:
- Requests
parameters:
- name: src_rse
in: query
description: The source rse.
schema:
type: array
items:
type: object
required:
- rse_id
properties:
rse_id:
description: The id of the rse.
type: string
- name: dest_rse
in: query
description: The destination rse.
schema:
type: array
items:
type: object
required:
- rse_id
properties:
rse_id:
description: The id of the rse.
type: string
- name: src_site
in: query
description: The source site.
schema:
type: string
- name: dest_site
in: query
description: The destination site.
schema:
type: string
- name: request_states
in: query
description: The accepted request states. Delimited by comma.
schema:
type: string
responses:
200:
description: OK
content:
application/x-json-stream:
schema:
description: All requests matching the arguments. Seperated by the new line character.
type: array
items:
description: A request.
type: object
properties:
id:
description: The id of the request.
type: string
request_type:
description: The request type.
type: string
enum: ["T", "U", "D", "I", "O"]
scope:
description: The scope of the transfer.
type: string
name:
description: The name of the transfer.
type: string
did_type:
description: The did type.
type: string
dest_rse_id:
description: The destination RSE id.
type: string
source_rse_id:
description: The source RSE id.
type: string
attributes:
description: All attributes associated with the request.
type: string
state:
description: The state of the request.
type: string
enum: ["Q", "G", "S", "F", "D", "L", "N", "O", "A", "M", "U", "W", "P"]
external_id:
description: External id of the request.
type: string
external_host:
description: External host of the request.
type: string
retry_count:
description: The numbers of attempted retires.
type: integer
err_msg:
description: An error message if one occured.
type: string
previous_attempt_id:
description: The id of the previous attempt.
type: string
rule_id:
description: The id of the associated replication rule.
type: string
activity:
description: The activity of the request.
type: string
bytes:
description: The size of the did in bytes.
type: integer
md5:
description: The md5 checksum of the did to transfer.
type: string
adler32:
description: The adler32 checksum of the did to transfer.
type: string
dest_url:
description: The destination url.
type: string
submitted_at:
description: The time the request got submitted.
type: string
started_at:
description: The time the request got started.
type: string
transferred_at:
description: The time the request got transfered.
type: string
estimated_at:
description: The time the request got estimated.
type: string
submitter_id:
description: The id of the submitter.
type: string
estimated_stated_at:
description: The estimation of the started at value.
type: string
estimated_transferred_at:
description: The estimation of the transfered at value.
type: string
staging_started_at:
description: The time the staging got started.
type: string
staging_finished_at:
description: The time the staging got finished.
type: string
account:
description: The account which issued the request.
type: string
requested_at:
description: The time the request got requested.
type: string
priority:
description: The priority of the request.
type: integer
transfertool:
description: The transfertool used.
type: string
source_rse:
description: The name of the source RSE.
type: string
dest_rse:
description: The name of the destination RSE.
type: string
401:
description: Invalid Auth Token
404:
description: Not found
406:
description: Not acceptable
"""
src_rse = flask.request.args.get('src_rse', default=None)
dst_rse = flask.request.args.get('dst_rse', default=None)
src_site = flask.request.args.get('src_site', default=None)
dst_site = flask.request.args.get('dst_site', default=None)
request_states = flask.request.args.get('request_states', default=None)
if not request_states:
return generate_http_error_flask(400, 'MissingParameter', 'Request state is missing')
if src_rse and not dst_rse:
return generate_http_error_flask(400, 'MissingParameter', 'Destination RSE is missing')
elif dst_rse and not src_rse:
return generate_http_error_flask(400, 'MissingParameter', 'Source RSE is missing')
elif src_site and not dst_site:
return generate_http_error_flask(400, 'MissingParameter', 'Destination site is missing')
elif dst_site and not src_site:
return generate_http_error_flask(400, 'MissingParameter', 'Source site is missing')
try:
states = [RequestState(state) for state in request_states.split(',')]
except ValueError:
return generate_http_error_flask(400, 'Invalid', 'Request state value is invalid')
src_rses = []
dst_rses = []
if src_site:
src_rses = get_rses_with_attribute_value(key='site', value=src_site, vo=flask.request.environ.get('vo'))
if not src_rses:
return generate_http_error_flask(404, 'NotFound', f'Could not resolve site name {src_site} to RSE')
src_rses = [rse['rse_name'] for rse in src_rses]
dst_rses = get_rses_with_attribute_value(key='site', value=dst_site, vo=flask.request.environ.get('vo'))
if not dst_rses:
return generate_http_error_flask(404, 'NotFound', f'Could not resolve site name {dst_site} to RSE')
dst_rses = [rse['rse_name'] for rse in dst_rses]
else:
dst_rses = [dst_rse]
src_rses = [src_rse]
def generate(issuer, vo):
for result in request.list_requests(src_rses, dst_rses, states, issuer=issuer, vo=vo):
yield render_json(**result) + '\n'
return try_stream(generate(issuer=flask.request.environ.get('issuer'), vo=flask.request.environ.get('vo')))
class RequestHistoryList(ErrorHandlingMethodView):
""" REST API to get requests. """
@check_accept_header_wrapper_flask(['application/x-json-stream'])
def get(self):
"""
---
summary: List Historic Requests
description: List historical requests for a given source and destination RSE or site.
tags:
- Requests
parameters:
- name: src_rse
in: query
description: The source rse.
schema:
type: array
items:
type: object
required:
- rse_id
properties:
rse_id:
description: The id of the rse.
type: string
- name: dest_rse
in: query
description: The destination rse.
schema:
type: array
items:
type: object
required:
- rse_id
properties:
rse_id:
description: The id of the rse.
type: string
- name: src_site
in: query
description: The source site.
schema:
type: string
- name: dest_site
in: query
description: The destination site.
schema:
type: string
- name: request_states
in: query
description: The accepted request states. Delimited by comma.
schema:
type: string
- name: offset
in: query
description: The offset of the list.
schema:
type: integer
default: 0
- name: limit
in: query
description: The maximum number of items to return.
schema:
type: integer
default: 100
responses:
200:
description: OK
content:
application/x-json-stream:
schema:
description: All requests matching the arguments. Seperated by a new line character.
type: array
items:
description: A request.
type: object
properties:
id:
description: The id of the request.
type: string
request_type:
description: The request type.
type: string
enum: ["T", "U", "D", "I", "O"]
scope:
description: The scope of the transfer.
type: string
name:
description: The name of the transfer.
type: string
did_type:
description: The did type.
type: string
dest_rse_id:
description: The destination RSE id.
type: string
source_rse_id:
description: The source RSE id.
type: string
attributes:
description: All attributes associated with the request.
type: string
state:
description: The state of the request.
type: string
enum: ["Q", "G", "S", "F", "D", "L", "N", "O", "A", "M", "U", "W", "P"]
external_id:
description: External id of the request.
type: string
external_host:
description: External host of the request.
type: string
retry_count:
description: The numbers of attempted retires.
type: integer
err_msg:
description: An error message if one occured.
type: string
previous_attempt_id:
description: The id of the previous attempt.
type: string
rule_id:
description: The id of the associated replication rule.
type: string
activity:
description: The activity of the request.
type: string
bytes:
description: The size of the did in bytes.
type: integer
md5:
description: The md5 checksum of the did to transfer.
type: string
adler32:
description: The adler32 checksum of the did to transfer.
type: string
dest_url:
description: The destination url.
type: string
submitted_at:
description: The time the request got submitted.
type: string
started_at:
description: The time the request got started.
type: string
transferred_at:
description: The time the request got transfered.
type: string
estimated_at:
description: The time the request got estimated.
type: string
submitter_id:
description: The id of the submitter.
type: string
estimated_stated_at:
description: The estimation of the started at value.
type: string
estimated_transferred_at:
description: The estimation of the transfered at value.
type: string
staging_started_at:
description: The time the staging got started.
type: string
staging_finished_at:
description: The time the staging got finished.
type: string
account:
description: The account which issued the request.
type: string
requested_at:
description: The time the request got requested.
type: string
priority:
description: The priority of the request.
type: integer
transfertool:
description: The transfertool used.
type: string
source_rse:
description: The name of the source RSE.
type: string
dest_rse:
description: The name of the destination RSE.
type: string
401:
description: Invalid Auth Token
404:
description: Not found
406:
description: Not acceptable
"""
src_rse = flask.request.args.get('src_rse', default=None)
dst_rse = flask.request.args.get('dst_rse', default=None)
src_site = flask.request.args.get('src_site', default=None)
dst_site = flask.request.args.get('dst_site', default=None)
request_states = flask.request.args.get('request_states', default=None)
offset = flask.request.args.get('offset', default=0)
limit = flask.request.args.get('limit', default=100)
if not request_states:
return generate_http_error_flask(400, 'MissingParameter', 'Request state is missing')
if src_rse and not dst_rse:
return generate_http_error_flask(400, 'MissingParameter', 'Destination RSE is missing')
elif dst_rse and not src_rse:
return generate_http_error_flask(400, 'MissingParameter', 'Source RSE is missing')
elif src_site and not dst_site:
return generate_http_error_flask(400, 'MissingParameter', 'Destination site is missing')
elif dst_site and not src_site:
return generate_http_error_flask(400, 'MissingParameter', 'Source site is missing')
try:
states = [RequestState(state) for state in request_states.split(',')]
except ValueError:
return generate_http_error_flask(400, 'Invalid', 'Request state value is invalid')
src_rses = []
dst_rses = []
if src_site:
src_rses = get_rses_with_attribute_value(key='site', value=src_site, vo=flask.request.environ.get('vo'))
if not src_rses:
return generate_http_error_flask(404, 'NotFound', f'Could not resolve site name {src_site} to RSE')
src_rses = [rse['rse_name'] for rse in src_rses]
dst_rses = get_rses_with_attribute_value(key='site', value=dst_site, vo=flask.request.environ.get('vo'))
if not dst_rses:
return generate_http_error_flask(404, 'NotFound', f'Could not resolve site name {dst_site} to RSE')
dst_rses = [rse['rse_name'] for rse in dst_rses]
else:
dst_rses = [dst_rse]
src_rses = [src_rse]
def generate(issuer, vo):
for result in request.list_requests_history(src_rses, dst_rses, states, issuer=issuer, vo=vo, offset=offset, limit=limit):
yield render_json(**result) + '\n'
return try_stream(generate(issuer=flask.request.environ.get('issuer'), vo=flask.request.environ.get('vo')))
class RequestMetricsGet(ErrorHandlingMethodView):
""" REST API to get request stats. """
@check_accept_header_wrapper_flask(['application/x-json-stream'])
def get(self):
"""
---
summary: Get Request Statistics
description: Get statistics of requests grouped by source, destination, and activity.
tags:
- Requests
parameters:
- name: dest_rse
in: query
description: The destination RSE name
schema:
type: string
- name: source_rse
in: query
description: The source RSE name
schema:
type: string
- name: activity
in: query
description: The activity
schema:
type: string
- name: group_by_rse_attribute
in: query
description: The parameter to group the RSEs by.
schema:
type: string
responses:
200:
description: OK
content:
application/x-json-stream:
schema:
description: Statistics of requests by source, destination, and activity.
type: array
items:
description: Statistics of the request group for a given (source, destination, activity) tuple.
type: object
properties:
src_rse:
type: string
description: The name of this links source RSE
dst_rse:
type: string
description: The name of this links destination RSE
distance:
type: integer
description: The distance between the source and destination RSE
files:
type: object
properties:
done-total-1h:
type: integer
description: The total number of files successfully transferred in the last 1 hour
done-total-6h:
type: integer
description: The total number of files successfully transferred in the last 6 hours
failed-total-1h:
type: integer
description: The total number of transfer failures in the last 1 hour
failed-total-6h:
type: integer
description: The total number of transfer failures in the last 6 hours
queued-total:
type: integer
description: The total number of files queued in rucio
queued:
type: object
description: Per-activity number of queued files
additionalProperties:
type: integer
done:
type: object
additionalProperties:
type: object
properties:
1h:
type: integer
6h:
type: integer
failed:
type: object
description: Per-activity number of transfer failures in the last 1 and 6 hours
additionalProperties:
type: object
properties:
1h:
type: integer
6h:
type: integer
bytes:
type: object
properties:
done-total-1h:
type: integer
description: The total number of bytes successfully transferred in the last 1 hour
done-total-6h:
type: integer
description: The total number of bytes successfully transferred in the last 6 hours
queued-total:
type: integer
description: The total number of bytes queued to be transferred by rucio
queued:
type: object
description: Per-activity amount of queued bytes
additionalProperties:
type: integer
done:
type: object
description: Per-activity number of transferred bytes in the last 1 and 6 hours
additionalProperties:
type: object
properties:
1h:
type: integer
6h:
type: integer
required:
- distance
- src_rse
- dst_rse
401:
description: Invalid Auth Token
"""
dst_rse = flask.request.args.get('dst_rse', default=None)
src_rse = flask.request.args.get('src_rse', default=None)
activity = flask.request.args.get('activity', default=None)
group_by_rse_attribute = flask.request.args.get('group_by_rse_attribute', default=None)
format = flask.request.args.get('format', default=None)
metrics = request.get_request_metrics(
dst_rse=dst_rse,
src_rse=src_rse,
activity=activity,
group_by_rse_attribute=group_by_rse_attribute,
issuer=flask.request.environ.get('issuer'),
vo=flask.request.environ.get('vo')
)
if format == 'panda':
return Response(json.dumps(metrics, cls=APIEncoder), content_type='application/json')
def generate() -> "Iterator[str]":
for result in metrics.values():
yield render_json(**result) + '\n'
return try_stream(generate())
def blueprint():
bp = AuthenticatedBlueprint('requests', __name__, url_prefix='/requests')
request_get_view = RequestGet.as_view('request_get')
bp.add_url_rule('/<path:scope_name>/<rse>', view_func=request_get_view, methods=['get', ])
request_history_get_view = RequestHistoryGet.as_view('request_history_get')
bp.add_url_rule('/history/<path:scope_name>/<rse>', view_func=request_history_get_view, methods=['get', ])
request_list_view = RequestList.as_view('request_list')
bp.add_url_rule('/list', view_func=request_list_view, methods=['get', ])
request_history_list_view = RequestHistoryList.as_view('request_history_list')
bp.add_url_rule('/history/list', view_func=request_history_list_view, methods=['get', ])
request_metrics_view = RequestMetricsGet.as_view('request_metrics_get')
bp.add_url_rule('/metrics', view_func=request_metrics_view, methods=['get', ])
bp.after_request(response_headers)
return bp
def make_doc():
""" Only used for sphinx documentation """
doc_app = Flask(__name__)
doc_app.register_blueprint(blueprint())
return doc_app