// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/oracle/oci-go-sdk/v65/aidocument"
	"github.com/oracle/oci-go-sdk/v65/common"
	"github.com/oracle/oci-go-sdk/v65/example/helpers"
)

func ExampleAnalyzeDocument() {
	// Create a default authentication provider that uses the DEFAULT
	// profile in the configuration file.
	// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
	client, err := aidocument.NewAIServiceDocumentClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).

	req := aidocument.AnalyzeDocumentRequest{AnalyzeDocumentDetails: aidocument.AnalyzeDocumentDetails{OcrData: &aidocument.AnalyzeDocumentResult{BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
		DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
			PageCount: common.Int(536)},
		KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
		Pages: []aidocument.Page{aidocument.Page{PageNumber: common.Int(849),
			SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5850377),
				Y: common.Float64(0.044899225)}}},
				Confidence: common.Float32(0.94672906),
				State:      aidocument.SelectionMarkStateUnselected}},
			Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.91044587),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.09648919),
					Y: common.Float64(0.6965759)}}}}},
			Tables: []aidocument.Table{aidocument.Table{Confidence: common.Float32(0.7323872),
				HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6061945),
					Y: common.Float64(0.031799674)}}},
					ColumnIndex: common.Int(508),
					Confidence:  common.Float32(0.31533659),
					RowIndex:    common.Int(98),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{68}}}}},
				RowCount: common.Int(56),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.3057726),
					Y: common.Float64(0.9044405)}}},
				ColumnCount: common.Int(994)}},
			BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.22802961),
				Y: common.Float64(0.5512688)}}},
				CodeType:   common.String("EXAMPLE-codeType-Value"),
				Confidence: common.Float32(0.22066593),
				Value:      common.String("EXAMPLE-value-Value")}},
			Lines: []aidocument.Line{aidocument.Line{WordIndexes: []int{678},
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.3821035),
					Y: common.Float64(0.3541156)}}},
				Confidence: common.Float32(0.7572835),
				Text:       common.String("EXAMPLE-text-Value")}},
			Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.40056372),
				Y: common.Float64(0.23701948)}}},
				Confidence: common.Float32(0.030065954),
				Text:       common.String("EXAMPLE-text-Value")}},
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.6554321),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}},
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.6725511),
				Language: common.String("EXAMPLE-language-Value")}},
			Dimensions: &aidocument.Dimensions{Height: common.Float64(8028.5674),
				Unit:  aidocument.DimensionsUnitPixel,
				Width: common.Float64(5438.6035)},
			DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.051778257),
				Name: common.String("EXAMPLE-name-Value")},
				FieldName: &aidocument.FieldName{Confidence: common.Float32(0.87662697),
					Name:        common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{219},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6283201),
						Y: common.Float64(0.022303224)}}}},
				FieldType: aidocument.DocumentFieldFieldTypeLineItemField,
				FieldValue: aidocument.ValueDate{NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
					Text:        common.String("EXAMPLE-text-Value"),
					Value:       &common.SDKTime{Time: time.Now()},
					WordIndexes: []int{284},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.62815845),
						Y: common.Float64(0.6552522)}}},
					Confidence:           common.Float32(0.121564746),
					NormalizedConfidence: common.Float32(0.13260484)}}}}},
		SearchablePdf:                   []byte("fyehGKr7j096hFcsUazI"),
		SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
		TableExtractionModelVersion:     common.String("EXAMPLE-tableExtractionModelVersion-Value"),
		TextExtractionModelVersion:      common.String("EXAMPLE-textExtractionModelVersion-Value"),
		DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.4822247),
			DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
			DocumentType: common.String("EXAMPLE-documentType-Value")}},
		DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.292742),
			Language: common.String("EXAMPLE-language-Value")}},
		DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
		Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
			Message: common.String("EXAMPLE-message-Value")}},
		LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value")},
		OutputLocation: &aidocument.OutputLocation{BucketName: common.String("EXAMPLE-bucketName-Value"),
			NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			Prefix:        common.String("EXAMPLE-prefix-Value")},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		Document: aidocument.InlineDocumentDetails{Data: []byte("piEwpyMx7ndHFNz16oht"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypeHealthInsuranceId,
		Features: []aidocument.DocumentFeature{aidocument.DocumentKeyValueExtractionFeature{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value"),
			TenancyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value")}},
		Language: common.String("EXAMPLE-language-Value")},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("DSY20DQS4HUTCQAXDVX3<unique_ID>")}

	// Send the request using the service client
	resp, err := client.AnalyzeDocument(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}