gazu 1.0.1__py2.py3-none-any.whl → 1.0.3__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gazu/project.py CHANGED
@@ -446,3 +446,415 @@ def remove_person_from_team(project, person, client=default):
446
446
  "data/projects/%s/team/%s" % (project["id"], person["id"]),
447
447
  client=client,
448
448
  )
449
+
450
+
451
+ @cache
452
+ def get_project_task_types(project, client=default):
453
+ """
454
+ Get task types configured for a project.
455
+
456
+ Args:
457
+ project (dict / ID): The project dict or id.
458
+
459
+ Returns:
460
+ list: The task types.
461
+ """
462
+ project = normalize_model_parameter(project)
463
+ return raw.fetch_all(
464
+ "projects/%s/settings/task-types" % project["id"], client=client
465
+ )
466
+
467
+
468
+ @cache
469
+ def get_project_task_statuses(project, client=default):
470
+ """
471
+ Get task statuses configured for a project.
472
+
473
+ Args:
474
+ project (dict / ID): The project dict or id.
475
+
476
+ Returns:
477
+ list: The task statuses.
478
+ """
479
+ project = normalize_model_parameter(project)
480
+ return raw.fetch_all(
481
+ "projects/%s/settings/task-status" % project["id"], client=client
482
+ )
483
+
484
+
485
+ @cache
486
+ def all_status_automations(project, client=default):
487
+ """
488
+ Get status automations configured for a project.
489
+
490
+ Args:
491
+ project (dict / ID): The project dict or id.
492
+
493
+ Returns:
494
+ list: The status automations.
495
+ """
496
+ project = normalize_model_parameter(project)
497
+ return raw.fetch_all(
498
+ "projects/%s/settings/status-automations" % project["id"],
499
+ client=client,
500
+ )
501
+
502
+
503
+ def add_status_automation(project, automation, client=default):
504
+ """
505
+ Add a status automation to the project.
506
+
507
+ Args:
508
+ project (dict / ID): The project dict or id.
509
+ automation (dict): The automation payload (e.g. from/to status, task_type, rules).
510
+ """
511
+ project = normalize_model_parameter(project)
512
+ return raw.post(
513
+ "data/projects/%s/settings/status-automations" % project["id"],
514
+ automation,
515
+ client=client,
516
+ )
517
+
518
+
519
+ def remove_status_automation(project, automation, client=default):
520
+ """
521
+ Remove a status automation from the project.
522
+
523
+ Args:
524
+ project (dict / ID): The project dict or id.
525
+ automation (dict / ID): The automation dict or id.
526
+ """
527
+ project = normalize_model_parameter(project)
528
+ automation = normalize_model_parameter(automation)
529
+ return raw.delete(
530
+ "data/projects/%s/settings/status-automations/%s"
531
+ % (project["id"], automation["id"]),
532
+ client=client,
533
+ )
534
+
535
+
536
+ @cache
537
+ def get_preview_background_files(project, client=default):
538
+ """
539
+ Get preview background files configured for a project.
540
+
541
+ Args:
542
+ project (dict / ID): The project dict or id.
543
+ """
544
+ project = normalize_model_parameter(project)
545
+ return raw.fetch_all(
546
+ "projects/%s/settings/preview-background-files" % project["id"], client=client
547
+ )
548
+
549
+
550
+ def add_preview_background_file(project, background_file, client=default):
551
+ """
552
+ Add a preview background file to a project.
553
+
554
+ The background_file payload must be a dict in the form:
555
+ {"preview_background_file_id": <background file id>}
556
+
557
+ Args:
558
+ project (dict / ID): The project dict or id.
559
+ background_file (dict): A dict with a key of "preview_background_file_id"
560
+ and value of the ID of the preview background to add.
561
+
562
+ Returns:
563
+ (dict): The project dictionary.
564
+ """
565
+ project = normalize_model_parameter(project)
566
+ return raw.post(
567
+ "data/projects/%s/settings/preview-background-files" % project["id"],
568
+ background_file,
569
+ client=client,
570
+ )
571
+
572
+
573
+ def remove_preview_background_file(project, background_file, client=default):
574
+ """
575
+ Remove a preview background file from a project.
576
+
577
+ Args:
578
+ project (dict / ID): The project dict or id.
579
+ background_file (dict / ID): The background file dict or id.
580
+ """
581
+ project = normalize_model_parameter(project)
582
+ background_file = normalize_model_parameter(background_file)
583
+ return raw.delete(
584
+ "data/projects/%s/settings/preview-background-files/%s"
585
+ % (project["id"], background_file["id"]),
586
+ client=client,
587
+ )
588
+
589
+
590
+ @cache
591
+ def get_milestones(project, client=default):
592
+ """
593
+ Get production milestones for a project.
594
+
595
+ Args:
596
+ project (dict / ID): The project dict or id.
597
+ """
598
+ project = normalize_model_parameter(project)
599
+ return raw.fetch_all(
600
+ "projects/%s/milestones" % project["id"], client=client
601
+ )
602
+
603
+
604
+ @cache
605
+ def get_project_quotas(project, client=default):
606
+ """
607
+ Get quotas for a project.
608
+
609
+ Args:
610
+ project (dict / ID): The project dict or id.
611
+ """
612
+ project = normalize_model_parameter(project)
613
+ return raw.fetch_all(
614
+ "projects/%s/quotas" % project["id"], client=client
615
+ )
616
+
617
+
618
+ @cache
619
+ def get_project_person_quotas(project, person, client=default):
620
+ """
621
+ Get quotas for a person within a project.
622
+
623
+ Args:
624
+ project (dict / ID): The project dict or id.
625
+ person (dict / ID): The person dict or id.
626
+ """
627
+ project = normalize_model_parameter(project)
628
+ person = normalize_model_parameter(person)
629
+ return raw.fetch_all(
630
+ "projects/%s/person-quotas" % project["id"],
631
+ params={"person_id": person["id"]},
632
+ client=client,
633
+ )
634
+
635
+
636
+ @cache
637
+ def get_budgets(project, client=default):
638
+ """
639
+ Get budgets for a project.
640
+
641
+ Args:
642
+ project (dict / ID): The project dict or id.
643
+ """
644
+ project = normalize_model_parameter(project)
645
+ return raw.fetch_all("projects/%s/budgets" % project["id"], client=client)
646
+
647
+
648
+ def create_budget(
649
+ project,
650
+ name,
651
+ description=None,
652
+ currency=None,
653
+ start_date=None,
654
+ end_date=None,
655
+ amount=None,
656
+ client=default,
657
+ ):
658
+ """
659
+ Create a budget for a project.
660
+
661
+ Args:
662
+ project (dict / ID): The project dict or id.
663
+ name (str): Budget name. Required.
664
+ description (str, optional): Human description.
665
+ currency (str, optional): Currency code (e.g. "USD", "EUR").
666
+ start_date (str, optional): Start date ISO format (YYYY-MM-DD).
667
+ end_date (str, optional): End date ISO format (YYYY-MM-DD).
668
+ amount (number, optional): Overall budget amount.
669
+ """
670
+ project = normalize_model_parameter(project)
671
+ data = {"name": name}
672
+ if description is not None:
673
+ data["description"] = description
674
+ if currency is not None:
675
+ data["currency"] = currency
676
+ if start_date is not None:
677
+ data["start_date"] = start_date
678
+ if end_date is not None:
679
+ data["end_date"] = end_date
680
+ if amount is not None:
681
+ data["amount"] = amount
682
+ return raw.post(
683
+ "data/projects/%s/budgets" % project["id"], data, client=client
684
+ )
685
+
686
+
687
+ @cache
688
+ def get_budget(project, budget, client=default):
689
+ """
690
+ Get a specific budget.
691
+
692
+ Args:
693
+ project (dict / ID): The project dict or id.
694
+ budget (dict / ID): The budget dict or id.
695
+ """
696
+ project = normalize_model_parameter(project)
697
+ budget = normalize_model_parameter(budget)
698
+ return raw.fetch_one(
699
+ "projects/%s/budgets" % project["id"], budget["id"], client=client
700
+ )
701
+
702
+
703
+ def update_budget(project, budget, data, client=default):
704
+ """
705
+ Update a specific budget.
706
+
707
+ Args:
708
+ project (dict / ID): The project dict or id.
709
+ budget (dict / ID): The budget dict or id.
710
+ data (dict): The updated budget payload.
711
+ """
712
+ project = normalize_model_parameter(project)
713
+ budget = normalize_model_parameter(budget)
714
+ return raw.put(
715
+ "data/projects/%s/budgets/%s" % (project["id"], budget["id"]),
716
+ data,
717
+ client=client,
718
+ )
719
+
720
+
721
+ def remove_budget(project, budget, client=default):
722
+ """
723
+ Delete a specific budget.
724
+
725
+ Args:
726
+ project (dict / ID): The project dict or id.
727
+ budget (dict / ID): The budget dict or id.
728
+ """
729
+ project = normalize_model_parameter(project)
730
+ budget = normalize_model_parameter(budget)
731
+ return raw.delete(
732
+ "data/projects/%s/budgets/%s" % (project["id"], budget["id"]),
733
+ client=client,
734
+ )
735
+
736
+
737
+ @cache
738
+ def get_budget_entries(project, budget, client=default):
739
+ """
740
+ Get entries for a specific budget.
741
+
742
+ Args:
743
+ project (dict / ID): The project dict or id.
744
+ budget (dict / ID): The budget dict or id.
745
+ """
746
+ project = normalize_model_parameter(project)
747
+ budget = normalize_model_parameter(budget)
748
+ return raw.fetch_all(
749
+ "projects/%s/budgets/%s/entries" % (project["id"], budget["id"]),
750
+ client=client,
751
+ )
752
+
753
+
754
+ def create_budget_entry(
755
+ project,
756
+ budget,
757
+ name,
758
+ date=None,
759
+ amount=None,
760
+ quantity=None,
761
+ unit_price=None,
762
+ description=None,
763
+ category=None,
764
+ client=default,
765
+ ):
766
+ """
767
+ Create a budget entry for a specific budget.
768
+
769
+ Args:
770
+ project (dict / ID): The project dict or id.
771
+ budget (dict / ID): The budget dict or id.
772
+ name (str): Entry name. Required.
773
+ date (str, optional): Entry date in ISO format (YYYY-MM-DD).
774
+ amount (number, optional): Total amount for the entry.
775
+ quantity (number, optional): Quantity used to compute amount.
776
+ unit_price (number, optional): Unit price used with quantity.
777
+ description (str, optional): Human description for the entry.
778
+ category (str, optional): Category label for the entry.
779
+ """
780
+ project = normalize_model_parameter(project)
781
+ budget = normalize_model_parameter(budget)
782
+ data = {"name": name}
783
+ if date is not None:
784
+ data["date"] = date
785
+ if amount is not None:
786
+ data["amount"] = amount
787
+ if quantity is not None:
788
+ data["quantity"] = quantity
789
+ if unit_price is not None:
790
+ data["unit_price"] = unit_price
791
+ if description is not None:
792
+ data["description"] = description
793
+ if category is not None:
794
+ data["category"] = category
795
+ return raw.post(
796
+ "data/projects/%s/budgets/%s/entries"
797
+ % (project["id"], budget["id"]),
798
+ data,
799
+ client=client,
800
+ )
801
+
802
+
803
+ @cache
804
+ def get_budget_entry(project, budget, entry, client=default):
805
+ """
806
+ Get a specific budget entry.
807
+
808
+ Args:
809
+ project (dict / ID): The project dict or id.
810
+ budget (dict / ID): The budget dict or id.
811
+ entry (dict / ID): The budget entry dict or id.
812
+ """
813
+ project = normalize_model_parameter(project)
814
+ budget = normalize_model_parameter(budget)
815
+ entry = normalize_model_parameter(entry)
816
+ return raw.fetch_one(
817
+ "projects/%s/budgets/%s/entries" % (project["id"], budget["id"]),
818
+ entry["id"],
819
+ client=client,
820
+ )
821
+
822
+
823
+ def update_budget_entry(project, budget, entry, data, client=default):
824
+ """
825
+ Update a specific budget entry.
826
+
827
+ Args:
828
+ project (dict / ID): The project dict or id.
829
+ budget (dict / ID): The budget dict or id.
830
+ entry (dict / ID): The budget entry dict or id.
831
+ data (dict): The updated budget entry payload.
832
+ """
833
+ project = normalize_model_parameter(project)
834
+ budget = normalize_model_parameter(budget)
835
+ entry = normalize_model_parameter(entry)
836
+ return raw.put(
837
+ "data/projects/%s/budgets/%s/entries/%s"
838
+ % (project["id"], budget["id"], entry["id"]),
839
+ data,
840
+ client=client,
841
+ )
842
+
843
+
844
+ def remove_budget_entry(project, budget, entry, client=default):
845
+ """
846
+ Delete a specific budget entry.
847
+
848
+ Args:
849
+ project (dict / ID): The project dict or id.
850
+ budget (dict / ID): The budget dict or id.
851
+ entry (dict / ID): The budget entry dict or id.
852
+ """
853
+ project = normalize_model_parameter(project)
854
+ budget = normalize_model_parameter(budget)
855
+ entry = normalize_model_parameter(entry)
856
+ return raw.delete(
857
+ "data/projects/%s/budgets/%s/entries/%s"
858
+ % (project["id"], budget["id"], entry["id"]),
859
+ client=client,
860
+ )
gazu/search.py ADDED
@@ -0,0 +1,35 @@
1
+ from . import client as raw
2
+
3
+ from .helpers import normalize_model_parameter
4
+
5
+ default = raw.default_client
6
+
7
+
8
+ def search_entities(query, project=None, entity_types=None, client=default):
9
+ """
10
+ Search for entities matching the given query.
11
+
12
+ Args:
13
+ query (str): Search query string.
14
+ project (dict / ID): Optional project to limit search to.
15
+ entity_types (list): Optional list of entity type dicts or IDs to filter by.
16
+
17
+ Returns:
18
+ dict: Dictionary with entity type keys ("persons", "assets", "shots")
19
+ containing lists of matching entities for each type.
20
+ """
21
+ data = {"query": query}
22
+
23
+ if project is not None:
24
+ project = normalize_model_parameter(project)
25
+ data["project_id"] = project["id"]
26
+
27
+ if entity_types is not None:
28
+ entity_type_ids = [
29
+ normalize_model_parameter(entity_type)["id"]
30
+ for entity_type in entity_types
31
+ ]
32
+ data["entity_types"] = entity_type_ids
33
+
34
+ return raw.post("data/search", data, client=client)
35
+