pangea-sdk 6.2.0b2__py3-none-any.whl → 6.4.0__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.
@@ -11,7 +11,7 @@ import enum
11
11
  from typing import Any, Dict, List, Optional, Sequence, Union
12
12
 
13
13
  from pydantic import Field
14
- from typing_extensions import Annotated, Literal
14
+ from typing_extensions import Annotated
15
15
 
16
16
  from pangea.response import APIRequestModel, APIResponseModel, PangeaDateTime, PangeaResponseResult
17
17
 
@@ -120,20 +120,25 @@ class Event(Dict[str, Any]):
120
120
 
121
121
 
122
122
  class EventEnvelope(APIResponseModel):
123
- """
124
- Contain extra information about an event.
123
+ event: Optional[dict[str, Any]] = None
125
124
 
126
- Arguments:
127
- event -- Event describing auditable activity.
128
- signature -- An optional client-side signature for forgery protection.
129
- public_key -- The base64-encoded ed25519 public key used for the signature, if one is provided
130
- received_at -- A server-supplied timestamp
125
+ signature: Optional[str] = None
126
+ """
127
+ This is the signature of the hash of the canonicalized event that can be
128
+ verified with the public key provided in the public_key field. Signatures
129
+ cannot be used with the redaction feature turned on. If redaction is
130
+ required, the user needs to perform redaction before computing the signature
131
+ that is to be sent with the message. The SDK facilitates this for users.
131
132
  """
132
133
 
133
- event: Dict[str, Any]
134
- signature: Optional[str] = None
135
134
  public_key: Optional[str] = None
136
- received_at: PangeaDateTime
135
+ """
136
+ The base64-encoded ed25519 public key used for the signature, if one is
137
+ provided
138
+ """
139
+
140
+ received_at: Optional[PangeaDateTime] = None
141
+ """A Pangea provided timestamp of when the event was received."""
137
142
 
138
143
 
139
144
  class LogRequest(APIRequestModel):
@@ -184,21 +189,28 @@ class LogBulkRequest(APIRequestModel):
184
189
 
185
190
 
186
191
  class LogResult(PangeaResponseResult):
192
+ envelope: Optional[EventEnvelope] = None
187
193
  """
188
- Result class after an audit log action
189
-
190
- envelope -- Event envelope information.
191
- hash -- Event envelope hash.
192
- unpublished_root -- The current unpublished root.
193
- membership_proof -- A proof for verifying the unpublished root.
194
- consistency_proof -- If prev_root was present in the request, this proof verifies that the new unpublished root is a continuation of the prev_root
194
+ The sealed envelope containing the event that was logged. Includes event
195
+ metadata such as optional client-side signature details and server-added
196
+ timestamps.
195
197
  """
196
198
 
197
- envelope: Optional[EventEnvelope] = None
198
- hash: str
199
+ hash: Annotated[Optional[str], Field(max_length=64, min_length=64)] = None
200
+ """The hash of the event data."""
201
+
199
202
  unpublished_root: Optional[str] = None
203
+ """The current unpublished root."""
204
+
200
205
  membership_proof: Optional[str] = None
206
+ """A proof for verifying that the buffer_root contains the received event"""
207
+
201
208
  consistency_proof: Optional[List[str]] = None
209
+ """
210
+ If prev_buffer_root was present in the request, this proof verifies that the
211
+ new unpublished root is a continuation of prev_unpublished_root
212
+ """
213
+
202
214
  consistency_verification: EventVerification = EventVerification.NONE
203
215
  membership_verification: EventVerification = EventVerification.NONE
204
216
  signature_verification: EventVerification = EventVerification.NONE
@@ -361,29 +373,47 @@ class RootResult(PangeaResponseResult):
361
373
 
362
374
 
363
375
  class SearchEvent(APIResponseModel):
376
+ envelope: EventEnvelope
377
+
378
+ membership_proof: Optional[str] = None
379
+ """A cryptographic proof that the record has been persisted in the log"""
380
+
381
+ hash: Annotated[Optional[str], Field(max_length=64, min_length=64)] = None
382
+ """The record's hash"""
383
+
384
+ published: Optional[bool] = None
385
+ """
386
+ If true, a root has been published after this event. If false, there is no
387
+ published root for this event
364
388
  """
365
- Event information received after a search request
366
389
 
367
- Arguments:
368
- envelope -- Event related information.
369
- hash -- The record's hash.
370
- leaf_index -- The index of the leaf of the Merkle Tree where this record was inserted.
371
- membership_proof -- A cryptographic proof that the record has been persisted in the log.
372
- consistency_verification -- Consistency verification calculated if required.
373
- membership_verification -- Membership verification calculated if required.
374
- signature_verification -- Signature verification calculated if required.
375
- fpe_context -- The context data needed to decrypt secure audit events that have been redacted with format preserving encryption.
390
+ imported: Optional[bool] = None
391
+ """
392
+ If true, the even was imported manually and not logged by the standard
393
+ procedure. Some features such as tamper proofing may not be available
376
394
  """
377
395
 
378
- envelope: EventEnvelope
379
- hash: str
380
- membership_proof: Optional[str] = None
381
- published: Optional[bool] = None
382
396
  leaf_index: Optional[int] = None
397
+ """
398
+ The index of the leaf of the Merkle Tree where this record was inserted or
399
+ null if published=false
400
+ """
401
+
402
+ valid_signature: Optional[bool] = None
403
+ """
404
+ Result of the verification of the Vault signature, if the event was signed
405
+ and the parameter `verify_signature` is `true`
406
+ """
407
+
408
+ fpe_context: Optional[str] = None
409
+ """
410
+ The context data needed to decrypt secure audit events that have been
411
+ redacted with format preserving encryption.
412
+ """
413
+
383
414
  consistency_verification: EventVerification = EventVerification.NONE
384
415
  membership_verification: EventVerification = EventVerification.NONE
385
416
  signature_verification: EventVerification = EventVerification.NONE
386
- fpe_context: Optional[str] = None
387
417
 
388
418
 
389
419
  class SearchResultOutput(PangeaResponseResult):
@@ -502,275 +532,3 @@ class ExportRequest(APIRequestModel):
502
532
  Whether or not to include the root hash of the tree and the membership proof
503
533
  for each record.
504
534
  """
505
-
506
-
507
- class AuditSchemaField(APIResponseModel):
508
- """A description of a field in an audit log."""
509
-
510
- id: str
511
- """Prefix name / identity for the field."""
512
-
513
- type: Literal["boolean", "datetime", "integer", "string", "string-unindexed", "text"]
514
- """The data type for the field."""
515
-
516
- description: Optional[str] = None
517
- """Human display description of the field."""
518
-
519
- name: Optional[str] = None
520
- """Human display name/title of the field."""
521
-
522
- redact: Optional[bool] = None
523
- """If true, redaction is performed against this field (if configured.) Only valid for string type."""
524
-
525
- required: Optional[bool] = None
526
- """If true, this field is required to exist in all logged events."""
527
-
528
- size: Optional[int] = None
529
- """The maximum size of the field. Only valid for strings, which limits number of UTF-8 characters."""
530
-
531
- ui_default_visible: Optional[bool] = None
532
- """If true, this field is visible by default in audit UIs."""
533
-
534
-
535
- class AuditSchema(APIResponseModel):
536
- """A description of acceptable fields for an audit log."""
537
-
538
- client_signable: Optional[bool] = None
539
- """If true, records contain fields to support client/vault signing."""
540
-
541
- save_malformed: Optional[str] = None
542
- """Save (or reject) malformed AuditEvents."""
543
-
544
- tamper_proofing: Optional[bool] = None
545
- """If true, records contain fields to support tamper-proofing."""
546
-
547
- fields: Optional[List[AuditSchemaField]] = None
548
- """List of field definitions."""
549
-
550
-
551
- class ForwardingConfiguration(APIResponseModel):
552
- """Configuration for forwarding audit logs to external systems."""
553
-
554
- type: str
555
- """Type of forwarding configuration."""
556
-
557
- forwarding_enabled: Optional[bool] = False
558
- """Whether forwarding is enabled."""
559
-
560
- event_url: Optional[str] = None
561
- """URL where events will be written to. Must use HTTPS."""
562
-
563
- ack_url: Optional[str] = None
564
- """If indexer acknowledgement is required, this must be provided along with a 'channel_id'."""
565
-
566
- channel_id: Optional[str] = None
567
- """An optional splunk channel included in each request if indexer acknowledgement is required."""
568
-
569
- public_cert: Optional[str] = None
570
- """Public certificate if a self signed TLS cert is being used."""
571
-
572
- index: Optional[str] = None
573
- """Optional splunk index passed in the record bodies."""
574
-
575
- vault_config_id: Optional[str] = None
576
- """The vault config used to store the HEC token."""
577
-
578
- vault_secret_id: Optional[str] = None
579
- """The secret ID where the HEC token is stored in vault."""
580
-
581
-
582
- class ServiceConfigV1(PangeaResponseResult):
583
- """Configuration options available for audit service"""
584
-
585
- id: Optional[str] = None
586
- """The config ID"""
587
-
588
- version: Literal[1] = 1
589
-
590
- created_at: Optional[str] = None
591
- """The DB timestamp when this config was created. Ignored when submitted."""
592
-
593
- updated_at: Optional[str] = None
594
- """The DB timestamp when this config was last updated at"""
595
-
596
- name: Optional[str] = None
597
- """Configuration name"""
598
-
599
- retention: Optional[str] = None
600
- """Retention window to store audit logs."""
601
-
602
- cold_query_result_retention: Optional[str] = None
603
- """Retention window for cold query result / state information."""
604
-
605
- hot_storage: Optional[str] = None
606
- """Retention window to keep audit logs in hot storage."""
607
-
608
- query_result_retention: Optional[str] = None
609
- """Length of time to preserve server-side query result caching."""
610
-
611
- redact_service_config_id: Optional[str] = None
612
- """A redact service config that will be used to redact PII from logs."""
613
-
614
- redaction_fields: Optional[List[str]] = None
615
- """Fields to perform redaction against."""
616
-
617
- vault_service_config_id: Optional[str] = None
618
- """A vault service config that will be used to sign logs."""
619
-
620
- vault_key_id: Optional[str] = None
621
- """ID of the Vault key used for signing. If missing, use a default Audit key"""
622
-
623
- vault_sign: Optional[bool] = None
624
- """Enable/disable event signing"""
625
-
626
-
627
- class ServiceConfigV2(PangeaResponseResult):
628
- """Configuration options available for audit service"""
629
-
630
- audit_schema: AuditSchema = Field(alias="schema")
631
- """Audit log field configuration. Only settable at create time."""
632
-
633
- version: Literal[2] = 2
634
-
635
- cold_query_result_retention: Optional[str] = None
636
- """Retention window for cold query result / state information."""
637
-
638
- created_at: Optional[str] = None
639
- """The DB timestamp when this config was created. Ignored when submitted."""
640
-
641
- hot_storage: Optional[str] = None
642
- """Retention window to keep audit logs in hot storage."""
643
-
644
- id: Optional[str] = None
645
- """The config ID"""
646
-
647
- name: Optional[str] = None
648
- """Configuration name"""
649
-
650
- query_result_retention: Optional[str] = None
651
- """Length of time to preserve server-side query result caching."""
652
-
653
- redact_service_config_id: Optional[str] = None
654
- """A redact service config that will be used to redact PII from logs."""
655
-
656
- retention: Optional[str] = None
657
- """Retention window to store audit logs."""
658
-
659
- updated_at: Optional[str] = None
660
- """The DB timestamp when this config was last updated at"""
661
-
662
- vault_key_id: Optional[str] = None
663
- """ID of the Vault key used for signing. If missing, use a default Audit key"""
664
-
665
- vault_service_config_id: Optional[str] = None
666
- """A vault service config that will be used to sign logs."""
667
-
668
- vault_sign: Optional[bool] = None
669
- """Enable/disable event signing"""
670
-
671
- forwarding_configuration: Optional[ForwardingConfiguration] = None
672
- """Configuration for forwarding audit logs to external systems."""
673
-
674
-
675
- class ServiceConfigV3(PangeaResponseResult):
676
- """Configuration options available for audit service"""
677
-
678
- audit_schema: AuditSchema = Field(alias="schema")
679
- """Audit log field configuration. Only settable at create time."""
680
-
681
- version: Literal[3] = 3
682
- """Version of the service config."""
683
-
684
- cold_storage: Optional[str] = None
685
- """Retention window for logs in cold storage. Deleted afterwards."""
686
-
687
- created_at: Optional[str] = None
688
- """The DB timestamp when this config was created. Ignored when submitted."""
689
-
690
- forwarding_configuration: Optional[ForwardingConfiguration] = None
691
- """Configuration for forwarding audit logs to external systems."""
692
-
693
- hot_storage: Optional[str] = None
694
- """Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards."""
695
-
696
- id: Optional[str] = None
697
- """The config ID"""
698
-
699
- name: Optional[str] = None
700
- """Configuration name"""
701
-
702
- redact_service_config_id: Optional[str] = None
703
- """A redact service config that will be used to redact PII from logs."""
704
-
705
- updated_at: Optional[str] = None
706
- """The DB timestamp when this config was last updated at"""
707
-
708
- vault_key_id: Optional[str] = None
709
- """ID of the Vault key used for signing. If missing, use a default Audit key"""
710
-
711
- vault_service_config_id: Optional[str] = None
712
- """A vault service config that will be used to sign logs."""
713
-
714
- vault_sign: Optional[bool] = None
715
- """Enable/disable event signing"""
716
-
717
- warm_storage: Optional[str] = None
718
- """Retention window for logs in warm storage. Migrated to cold or deleted afterwards."""
719
-
720
-
721
- ServiceConfig = Annotated[
722
- Union[ServiceConfigV1, ServiceConfigV2, ServiceConfigV3],
723
- Field(discriminator="version"),
724
- ]
725
- """Configuration options available for audit service"""
726
-
727
-
728
- class ServiceConfigFilter(APIRequestModel):
729
- id: Optional[str] = None
730
- """Only records where id equals this value."""
731
-
732
- id__contains: Optional[Sequence[str]] = None
733
- """Only records where id includes each substring."""
734
-
735
- id__in: Optional[Sequence[str]] = None
736
- """Only records where id equals one of the provided substrings."""
737
-
738
- created_at: Optional[str] = None
739
- """Only records where created_at equals this value."""
740
-
741
- created_at__gt: Optional[str] = None
742
- """Only records where created_at is greater than this value."""
743
-
744
- created_at__gte: Optional[str] = None
745
- """Only records where created_at is greater than or equal to this value."""
746
-
747
- created_at__lt: Optional[str] = None
748
- """Only records where created_at is less than this value."""
749
-
750
- created_at__lte: Optional[str] = None
751
- """Only records where created_at is less than or equal to this value."""
752
-
753
- updated_at: Optional[str] = None
754
- """Only records where updated_at equals this value."""
755
-
756
- updated_at__gt: Optional[str] = None
757
- """Only records where updated_at is greater than this value."""
758
-
759
- updated_at__gte: Optional[str] = None
760
- """Only records where updated_at is greater than or equal to this value."""
761
-
762
- updated_at__lt: Optional[str] = None
763
- """Only records where updated_at is less than this value."""
764
-
765
- updated_at__lte: Optional[str] = None
766
- """Only records where updated_at is less than or equal to this value."""
767
-
768
-
769
- class ServiceConfigListResult(PangeaResponseResult):
770
- count: int
771
- """The total number of service configs matched by the list request."""
772
-
773
- last: str
774
- """Used to fetch the next page of the current listing when provided in a repeated request's last parameter."""
775
-
776
- items: Sequence[ServiceConfig]
@@ -6,6 +6,7 @@
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ from collections.abc import Mapping
9
10
  from typing import Dict, List, Literal, Optional, Union
10
11
 
11
12
  import pangea.services.authn.models as m
@@ -437,7 +438,7 @@ class AuthN(ServiceBase):
437
438
  ):
438
439
  super().__init__(token, config, logger_name=logger_name)
439
440
 
440
- def check(self, token: str) -> PangeaResponse[m.ClientTokenCheckResult]:
441
+ def check(self, token: m.Token) -> PangeaResponse[m.ClientTokenCheckResult]:
441
442
  """
442
443
  Check a token
443
444
 
@@ -446,7 +447,7 @@ class AuthN(ServiceBase):
446
447
  OperationId: authn_post_v2_client_token_check
447
448
 
448
449
  Args:
449
- token (str): A token value
450
+ token: A token value
450
451
 
451
452
  Returns:
452
453
  A PangeaResponse with a token and its information in the response.result field.
@@ -458,10 +459,7 @@ class AuthN(ServiceBase):
458
459
  token="ptu_wuk7tvtpswyjtlsx52b7yyi2l7zotv4a",
459
460
  )
460
461
  """
461
- input = m.ClientTokenCheckRequest(token=token)
462
- return self.request.post(
463
- "v2/client/token/check", m.ClientTokenCheckResult, data=input.model_dump(exclude_none=True)
464
- )
462
+ return self.request.post("v2/client/token/check", m.ClientTokenCheckResult, data={"token": token})
465
463
 
466
464
  class User(ServiceBase):
467
465
  service_name = _SERVICE_NAME
@@ -481,7 +479,7 @@ class AuthN(ServiceBase):
481
479
  def create(
482
480
  self,
483
481
  email: str,
484
- profile: m.Profile,
482
+ profile: Mapping[str, str],
485
483
  *,
486
484
  username: str | None = None,
487
485
  ) -> PangeaResponse[m.UserCreateResult]:
@@ -868,7 +866,7 @@ class AuthN(ServiceBase):
868
866
 
869
867
  def update(
870
868
  self,
871
- profile: m.Profile,
869
+ profile: Mapping[str, str],
872
870
  id: str | None = None,
873
871
  email: str | None = None,
874
872
  *,