Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sample/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import Dict

from datacustomcode.entry_func import entry_func


@entry_func
def add(request: Dict[str, int]) -> Dict[str, int]:
"""Add two integers."""
a = request.get("a", 0)
b = request.get("b", 0)
return {"result": a + b}
37 changes: 37 additions & 0 deletions sample/add.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: 3.0.0
info:
title: Add Service
description: API generated from Python function schema
version: 1.0.0
paths:
/add:
post:
summary: Add two integers
description: Add two integers.
operationId: add
x-function:
language: python
namespace: salesforceOrg
package: dataCloudPkg
name: addFn
prototype: 'add(request: Dict[str, int]) -> Dict[str, int]'
description: Will perform add operation
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: integer
'400':
description: Invalid input
9 changes: 9 additions & 0 deletions sample/analyze.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Dict, List

from datacustomcode.entry_func import entry_func


@entry_func
def analyze(request: Dict[str, Dict[str, int]]) -> Dict[str, List[int]]:
"""Analyze data with nested configuration and return grouped results."""
return {}
41 changes: 41 additions & 0 deletions sample/analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
openapi: 3.0.0
info:
title: Analyze Service
description: API generated from Python function schema
version: 1.0.0
paths:
/analyze:
post:
summary: Analyze data with nested configuration and return grouped results
description: Analyze data with nested configuration and return grouped results.
operationId: analyze
x-function:
language: python
namespace: salesforceOrg
package: dataCloudPkg
name: analyzeFn
prototype: 'analyze(request: Dict[str, Dict[str, int]]) -> Dict[str, List[int]]'
description: Will perform analyze operation
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties:
type: object
additionalProperties:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: array
items:
type: integer
'400':
description: Invalid input
2 changes: 2 additions & 0 deletions sample/byoc_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
namespace: salesforceOrg
package: dataCloudPkg
11 changes: 11 additions & 0 deletions sample/greeting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import Dict

from datacustomcode.entry_func import entry_func


@entry_func
def greet(request: Dict[str, str]) -> Dict[str, str]:
"""Generate a personalized greeting message."""
name = request.get("name", "World")
greeting = request.get("greeting", "Hello")
return {"message": f"{greeting}, {name}!"}
37 changes: 37 additions & 0 deletions sample/greeting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: 3.0.0
info:
title: Greet Service
description: API generated from Python function schema
version: 1.0.0
paths:
/greet:
post:
summary: Generate a personalized greeting message
description: Generate a personalized greeting message.
operationId: greet
x-function:
language: python
namespace: salesforceOrg
package: dataCloudPkg
name: greetFn
prototype: 'greet(request: Dict[str, str]) -> Dict[str, str]'
description: Will perform greet operation
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties:
type: string
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: string
'400':
description: Invalid input
9 changes: 9 additions & 0 deletions sample/transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Dict, List

from datacustomcode.entry_func import entry_func


@entry_func
def transform(request: Dict[str, List[Dict[str, str]]]) -> Dict[str, List[Dict[str, str]]]:
"""Transform a list of records by remapping keys."""
return {}
46 changes: 46 additions & 0 deletions sample/transform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
openapi: 3.0.0
info:
title: Transform Service
description: API generated from Python function schema
version: 1.0.0
paths:
/transform:
post:
summary: Transform a list of records by remapping keys
description: Transform a list of records by remapping keys.
operationId: transform
x-function:
language: python
namespace: salesforceOrg
package: dataCloudPkg
name: transformFn
prototype: 'transform(request: Dict[str, List[Dict[str, str]]]) -> Dict[str,
List[Dict[str, str]]]'
description: Will perform transform operation
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties:
type: array
items:
type: object
additionalProperties:
type: string
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: array
items:
type: object
additionalProperties:
type: string
'400':
description: Invalid input
Loading