File tree Expand file tree Collapse file tree
src/sap_cloud_sdk/core/auditlog_ng Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Proto code generation for SAP Cloud SDK for Python
2+ # Requires: buf CLI (https://buf.build/docs/installation)
3+
4+ AUDITLOG_NG_DIR := src/sap_cloud_sdk/core/auditlog_ng
5+ GEN_DIR := $(AUDITLOG_NG_DIR ) /gen
6+ BUF_DIR := src/buf
7+
8+ .PHONY : proto
9+
10+ proto :
11+ # Generate code using buf CLI
12+ cd $(AUDITLOG_NG_DIR) && buf dep update && buf generate --include-imports
13+
14+ # Add __init__.py files to generated code
15+ find $(GEN_DIR) -type d -exec touch {}/__init__.py \;
16+
17+ # Move /buf generated code to the root
18+ rm -rf $(BUF_DIR);
19+ mv $(GEN_DIR)/buf $(BUF_DIR);
20+ rm -rf $(GEN_DIR)/buf;
21+
Original file line number Diff line number Diff line change 2929from sap_cloud_sdk .core .auditlog_ng .config import (
3030 AuditLogNGConfig ,
3131 SCHEMA_URL ,
32- validate_source_arg ,
3332)
3433from sap_cloud_sdk .core .auditlog_ng .exceptions import (
3534 AuditLogNGError ,
3837 ValidationError ,
3938)
4039
40+ from sap_cloud_sdk .core .telemetry import Module
41+
4142
4243def create_client (
4344 * ,
@@ -53,6 +54,7 @@ def create_client(
5354 batch : bool = False ,
5455 compression : bool = True ,
5556 schema_url : str = SCHEMA_URL ,
57+ _telemetry_source : Optional [Module ] = None
5658) -> AuditClient :
5759 """Create an AuditClient for sending audit events over OTLP/gRPC.
5860
@@ -102,7 +104,7 @@ def create_client(
102104 schema_url = schema_url ,
103105 )
104106
105- return AuditClient (config )
107+ return AuditClient (config , _telemetry_source = _telemetry_source )
106108
107109 except (ValueError , ValidationError ) as e :
108110 raise e
@@ -117,7 +119,6 @@ def create_client(
117119 "AuditClient" ,
118120 # Configuration
119121 "AuditLogNGConfig" ,
120- "SCHEMA_URL" ,
121122 # Exceptions
122123 "AuditLogNGError" ,
123124 "ClientCreationError" ,
Original file line number Diff line number Diff line change 1+ version : v2
2+ clean : true
3+ plugins :
4+ - remote : buf.build/protocolbuffers/python:v33.5
5+ out : gen
6+ include_imports : true
7+ - remote : buf.build/protocolbuffers/pyi:v33.5
8+ out : gen
9+ include_imports : true
Original file line number Diff line number Diff line change 1+ version : v2
2+ modules :
3+ - path : proto
4+ deps :
5+ - buf.build/bufbuild/protovalidate
Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ def send(
134134 RuntimeError: If the client has already been closed.
135135 ValueError: If *format* is not a supported value.
136136 ValidationError: If the protobuf event fails validation.
137+
138+ Note:
139+ A successful return does not guarantee delivery.
140+ The OTLP exporter operates asynchronously. Always use flush() before shutdown to maximize delivery probability.
137141 """
138142 if self ._closed :
139143 raise RuntimeError ("Client is closed" )
Original file line number Diff line number Diff line change @@ -13,12 +13,6 @@ class ClientCreationError(AuditLogNGError):
1313 pass
1414
1515
16- class TransportError (AuditLogNGError ):
17- """Raised when gRPC transport operations fail."""
18-
19- pass
20-
21-
2216class ValidationError (AuditLogNGError ):
2317 """Raised when audit event validation fails."""
2418
Original file line number Diff line number Diff line change 1+ // Custom options for protoc-gen-jsonschema
2+ // Allocated range is 1125-1129
3+ // See https://github.com/protocolbuffers/protobuf/blob/master/docs/options.md
4+
5+ syntax = "proto3" ;
6+ package protoc.gen.jsonschema.v1 ;
7+
8+ import "google/protobuf/descriptor.proto" ;
9+
10+ option go_package = "github.com/chrusty/protoc-gen-jsonschema" ;
11+
12+ // Custom FieldOptions
13+ message FieldOptions {
14+ // Fields tagged with this will be omitted from generated schemas
15+ bool ignore = 1 ;
16+
17+ // Fields tagged with this will be marked as "required" in generated schemas
18+ bool required = 2 ;
19+
20+ // Fields tagged with this will constrain strings using the "minLength" keyword in generated schemas
21+ int32 min_length = 3 ;
22+
23+ // Fields tagged with this will constrain strings using the "maxLength" keyword in generated schemas
24+ int32 max_length = 4 ;
25+
26+ // Fields tagged with this will constrain strings using the "pattern" keyword in generated schemas
27+ string pattern = 5 ;
28+ }
29+
30+ extend google.protobuf.FieldOptions {
31+ FieldOptions field_options = 1125 ;
32+ }
You can’t perform that action at this time.
0 commit comments