Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial REST API Updates #61

Merged
merged 2 commits into from
Mar 4, 2022
Merged
Changes from all 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
112 changes: 14 additions & 98 deletions labs/PiDay-2022-Vision/Lab-3-vision-rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,41 @@

## Introduction


In this lab session, we will show you how to access OCI Vision using POSTMAN.

Postman is a GUI-based REST API invocation tool that is very popular among developers.

*Estimated Lab Time*: 10 minutes

### Objectives:
* Learn how to access Language Service through REST APIs.
* Learn how to access Vision Service through REST APIs.

### Prerequisites:
* Basic knowledge of REST API calls.
* Postman GUI in your local setup. If you don't have POSTMAN, please download it from [POSTMAN](https://www.postman.com/downloads/)

## **TASK 1:** Setup API Signing Key and Config File
**Prerequisite: Before you generate a key pair, create the .oci directory in your home directory to store the credentials.**

Mac OS / Linux:

```
<copy>mkdir ~/.oci</copy>
```
Windows:
```
<copy>mkdir %HOMEDRIVE%%HOMEPATH%\.oci</copy>
```

Generate an API signing key pair

1. Open User Settings

Open the Profile menu (User menu icon) and click User Settings.
![](./images/userProfileIcon.png " ")

1. Open API Key

Navigate to API Key and then Click Add API Key.
![](./images/addAPIButton.png " ")

1. Generate API Key

In the dialog, select Generate API Key Pair. Click Download Private Key and save the key to your .oci directory and then click Add.
![](./images/genAPI.png " ")



4. Generate Config File

Copy the values shown on the console.
![](./images/conf.png " ")

Create a config file in the .oci folder and paste the values copied.
Replace the key_file value with the path of your generated API Key.
![](./images/config2.png " ")
## **TASK 1:** Setting Up Postman for OCI REST APIs
We have put together a Postman Collection and Environment to help you quickly get started with calling the Vision REST APIs.

1. Import the Vision Collection into Postman

Download the [Vision API Collection](https://www.postman.com/oracledevs/workspace/oracle-cloud-infrastructure-rest-apis/overview) and import the Collection into Postman using the 'Import' button at the top.

1. Import the OCI Credentials Environment into Postman

To Know more visit [Generating API KEY](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm) and [SDK and CLI Configuration File](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File)
Download the [OCI Credentials Environment](https://www.postman.com/oracledevs/workspace/oracle-cloud-infrastructure-rest-apis/environment/29850-eab82db8-e9a1-4200-9f39-de10b4a0f371) and import the Environment into Postman using the 'Import' button at the top.

## **TASK 2:** Setting Up Postman for OCI REST APIs
We have provided some scripts and steps below that can be used to allow invoking OCI REST APIs through Postman. Please follow the steps in the order described.
Make sure to set OCI Credentials as the active environment.

1. Import the environment into Postman
1. Set the Variables
Open and edit the newly imported environment (OCI Credentials), and set the variables tenancy_ocid, user_ocid, fingerprint, private_key, region, and compartment_ocid.

Download the [OCI Environment](./files/OCI_Environment.postman_environment.json) and import the environment into Postman using the 'Import' button at the top.
![](./images/importENV.png " ")

Make sure to set OCI_Environment as the active environment.
![](./images/setActive.png " ")

1. Set the Variables
Open and edit the newly imported environment (OCI_Environment), and set the variables tenancyId, authUserId, keyFingerprint and private Key. These are same that are found in the .oci file you created above in Task 1->Step4).

Make sure to set both Initial Value and Current Value of the variables(set both as the same value).
Make sure to set both Initial Value and Current Value of the variables (set both as the same value).

Click the Save button to commit your changes to the environment.
![](./images/setVar.png " ")

<!-- ### 5. Add Request in OCI REST COLLECTION

Add Request in the OCI REST COLLECTION Folder
![](./images/4.png " ")

Enter Name and click 'Save to OCI REST COLLECTION'
![](./images/5.png " ")

Just make sure that the OCI REST calls are executed as part of the OCI REST COLLECTION, as that collection contains the necessary javascript code to generate OCI's authentication header -->

## **TASK 3:** Invoke Language OCI REST APIs
** @Wes / @Mark - will need you guys to take this part over since I am not familiar with doing this in postman myself. **

Invoke Language OCI REST APIs by clicking any one of the requests in the OCI REST COLLECTION. Enter the text you want to analyze in the body as shown below:
```
<copy>{
"text" : "American football was derived from the European games of rugby and soccer. Unlike the game of soccer, however, American football focuses more on passing and catching the ball with the hands as opposed to kicking the ball with the feet. Standard American football field is 120 yards in length and 160 feet in width. They are hash marks on every yards and every 10 yards. American football is quickly become more popular then baseball and fan bases are increasing rapidly. Jerry Rice, Tom Brady and Lawrence Taylor are few top player of this sports."
}<copy>
```

Below in the example shown to invoke Detect Language Service.
![](./images/collectionREST.png " ")

OCI Language Service EndPoints for all the services:

```
# Language Detection
https://language.aiservice.us-ashburn-1.oci.oraclecloud.com/20210101/actions/detectDominantLanguage

# Key Phrase Extraction
https://language.aiservice.us-ashburn-1.oci.oraclecloud.com/20210101/actions/detectLanguageKeyPhrases

# Named Entity Recognition
https://language.aiservice.us-ashburn-1.oci.oraclecloud.com/20210101/actions/detectLanguageEntities

# Text Classification
https://language.aiservice.us-ashburn-1.oci.oraclecloud.com/20210101/actions/detectLanguageTextClassification

# Aspect-Based Sentiment Analysis
https://language.aiservice.us-ashburn-1.oci.oraclecloud.com/20210101/actions/detectLanguageSentiments
## **TASK 3:** Invoke Vision OCI REST APIs

```
##TODO

[Proceed to the next lab](#next).