Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5627e80

Browse files
committed
Merge branch 'batch3' of https://github.com/oracle/oracle-functions-samples into batch3
2 parents 6d1547c + b6b1eb6 commit 5627e80

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

‎samples/oci-oic-hcm-object-upload/README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@ ALL {resource.type = 'fnfunc', resource.compartment.id = 'ocid1.compartment.oc1.
3434
Please check the [Accessing Other Oracle Cloud Infrastructure Resources from Running Functions](https://docs.cloud.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsaccessingociresources.htm) for other *Matching Rules* options.
3535

3636

37-
## Create or Update IAM Policies
38-
Create a new policy that allows the dynamic group to manage compute instances. We will grant `inspect/use/manage` access to `xxx` in the compartment.
37+
## Create or Update IAM Policies for Dynamic Groups
38+
Create a new policy that allows the dynamic group to manage the Object Storage resource. We will grant `manage` access to allow our function to put objects into the Object Storage in the compartment.
3939

4040
![user input icon](./images/userinput.png)
4141

4242
Your policy should look something like this:
4343
```
44-
Allow dynamic-group <dynamic-group-name> to xxx XXX in compartment <compartment-name>
44+
Allow dynamic-group <dynamic-group-name> to manage object-family in compartment id <compartment-id>
45+
```
46+
e.g.
47+
```
48+
Allow dynamic-group oci-oic-fn-dynamic-group to manage object-family in compartment id ocid1.compartment.oc1..aaaaaaaa4233
4549
```
4650

4751
For more information on how to create policies, check the [documentation](https://docs.cloud.oracle.com/iaas/Content/Identity/Concepts/policysyntax.htm).
4852

49-
5053
## Review and customize the function
5154
Review the following files in the current folder:
5255
* the code of the function, [func.py](./processEmployee/func.py)
@@ -66,22 +69,26 @@ fn -v deploy --app <app-name>
6669
## Set the function configuration values
6770
The function requires the following configuration values to be set:
6871
- OCI_NAMESPACE
72+
- OCI_BUCKETNAME
6973

7074
![user input icon](./images/userinput.png)
7175

7276
Use the *fn CLI* to set the config value:
7377
```
7478
fn config function <app-name> <function-name> OCI_NAMESPACE <NAMESPACE>
79+
fn config function <app-name> <function-name> OCI_BUCKETNAME <BUCKETNAME>
7580
```
7681
e.g.
7782
```
7883
fn config function myapp OCI_NAMESPACE mynamespace
84+
fn config function myapp OCI_BUCKETNAME mybucket
7985
```
8086

8187
## Test the function
82-
```bash
83-
# After deploying the function and configuring the namespace, you can test the function by invoking:
88+
After deploying the function and configuring the namespace and the bucketname, you can test the function by invoking the function with a JSON payload as shown below.
8489

90+
![user input icon](./images/userinput.png)
91+
```bash
8592
echo -n "{
8693
'firstname': '',
8794
'lastname': '',
@@ -90,15 +97,19 @@ echo -n "{
9097
'effectivestartdate': '',
9198
'personid': ''
9299
}" | fn invoke <app-name> <function-name>
93-
94-
# where the json is the expected payload structure
95100
```
96101

97102
## Calling the function from OIC
98103
To call the function from OIC, you will have to have an integration using a REST adapter connection pointing to this function.
99104

100105

101-
To setup your REST connection in your integration, the option `Configure a request payload for this endpoint` in the Basic Info page must be *checked*. On the next tab, `Requests`, the below sample json needs to be set for the target data to appear inside the mapper.
106+
To setup your REST connection in your integration, the option `Configure a request payload for this endpoint` in the Basic Info page must be *checked*.
107+
108+
![Configure Request Payload Option on OIC](./images/configure-oic-request-payload-option.png)
109+
110+
On the next tab, `Requests`, the below sample json needs to be set for the target data to appear inside the mapper. Enter a sample JSON like the one below to describe the HTTP message payload. You can set this definition by click on `inline` as shown below.
111+
112+
![Configure Request Payload Definition on OIC](./images/configure-oic-payload-definition.png)
102113

103114
```bash
104115
{
@@ -113,6 +124,6 @@ To setup your REST connection in your integration, the option `Configure a reque
113124

114125
In the mapper connecting to the REST adapter connection, the data in the source needs to be mapped to the target. In this case, the source data is from a GET request pulling the information from Oracle Human Capital Management (HCM).
115126

116-
![Payload on OIC](./images/function-payload.png)
127+
![Payload Mapping on OIC](./images/function-payload.png)
117128

118129
An example of how this invocation is done from OIC can be found in this [documentation](https://docs.oracle.com/en/cloud/paas/integration-cloud/rest-adapter/configure-rest-adapter-consume-oracle-functions.html).
156 KB
Loading[フレーム]
155 KB
Loading[フレーム]

‎samples/oci-oic-hcm-object-upload/processEmployee/func.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
def handler(ctx, data: io.BytesIO = None):
1717

1818
signer = oci.auth.signers.get_resource_principals_signer()
19-
bucketname = "saas-oic-oci-poc"
2019

2120
try:
2221
cfg = ctx.Config()
2322
cfg_namespace = cfg["OCI_NAMESPACE"]
23+
cfg_bucketname = cfg["OCI_BUCKETNAME"]
2424
except Exception as ex:
2525
print("Error: Configuration key has not been set.", ex, flush=True)
2626
raise
@@ -40,7 +40,7 @@ def handler(ctx, data: io.BytesIO = None):
4040
filename = personid + "_data.csv"
4141
personinfo = personid + ", " + firstname + ", " + lastname + ", " + workemail + ", " + hiredate + ", " + effectivestartdate
4242

43-
return_output = put_object(signer, bucketname, filename, personinfo, cfg_namespace=cfg_namespace)
43+
return_output = put_object(signer, cfg_bucketname, filename, personinfo, cfg_namespace=cfg_namespace)
4444
return response.Response(
4545
ctx,
4646
response_data=json.dumps(return_output),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /