// 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{Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
		Message: common.String("EXAMPLE-message-Value")}},
		KeyValueExtractionModelVersion:     common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
		LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
		Pages: []aidocument.Page{aidocument.Page{BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.72568834),
			Y: common.Float64(0.106283486)}}},
			CodeType:   common.String("EXAMPLE-codeType-Value"),
			Confidence: common.Float32(0.45265162),
			Value:      common.String("EXAMPLE-value-Value")}},
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.52646816),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}},
			Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.41636652),
				Y: common.Float64(0.57773685)}}},
				Confidence: common.Float32(0.21610427)}},
			Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.01684624),
				Y: common.Float64(0.8739056)}}},
				ColumnCount: common.Int(680),
				Confidence:  common.Float32(0.94507504),
				HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.54761136),
					X: common.Float64(0.4554652)}}},
					ColumnIndex: common.Int(253),
					Confidence:  common.Float32(0.98582494),
					RowIndex:    common.Int(890),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{512}}}}},
				RowCount: common.Int(294)}},
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.7512802),
				Language: common.String("EXAMPLE-language-Value")}},
			Dimensions: &aidocument.Dimensions{Height: common.Float64(792.4867),
				Unit:  aidocument.DimensionsUnitPixel,
				Width: common.Float64(5299.169)},
			DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.33512008),
				Name: common.String("EXAMPLE-name-Value")},
				FieldName: &aidocument.FieldName{Name: common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{41},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.2368275),
						Y: common.Float64(0.6897356)}}},
					Confidence: common.Float32(0.3632174)},
				FieldType: aidocument.DocumentFieldFieldTypeLineItem,
				FieldValue: aidocument.ValueTime{NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
					Text:        common.String("EXAMPLE-text-Value"),
					Value:       &common.SDKTime{Time: time.Now()},
					WordIndexes: []int{598},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7266455),
						Y: common.Float64(0.86825913)}}},
					Confidence:           common.Float32(0.88014144),
					NormalizedConfidence: common.Float32(0.36755115)}}},
			Lines: []aidocument.Line{aidocument.Line{Text: common.String("EXAMPLE-text-Value"),
				WordIndexes: []int{560},
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.61615497),
					Y: common.Float64(0.7541344)}}},
				Confidence: common.Float32(0.26308787)}},
			PageNumber: common.Int(670),
			SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{State: aidocument.SelectionMarkStateUnselected,
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.41768825),
					Y: common.Float64(0.009836018)}}},
				Confidence: common.Float32(0.52240884)}},
			Words: []aidocument.Word{aidocument.Word{Text: common.String("EXAMPLE-text-Value"),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.5636895),
					X: common.Float64(0.5958512)}}},
				Confidence: common.Float32(0.09209776)}}}},
		TableExtractionModelVersion:   common.String("EXAMPLE-tableExtractionModelVersion-Value"),
		TextExtractionModelVersion:    common.String("EXAMPLE-textExtractionModelVersion-Value"),
		BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
		DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.7658252),
			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.944796),
			Language: common.String("EXAMPLE-language-Value")}},
		DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
		SearchablePdf:                      []byte("77lGhinbM3l29jIyu6y5"),
		SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
		DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
			PageCount: common.Int(320)}},
		OutputLocation: &aidocument.OutputLocation{NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			Prefix:     common.String("EXAMPLE-prefix-Value"),
			BucketName: common.String("EXAMPLE-bucketName-Value")},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		Document: aidocument.ObjectStorageDocumentDetails{NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			ObjectName: common.String("EXAMPLE-objectName-Value"),
			PageRange:  []string{"EXAMPLE--Value"},
			BucketName: common.String("EXAMPLE-bucketName-Value")},
		DocumentType: aidocument.DocumentTypeCheck,
		Features: []aidocument.DocumentFeature{aidocument.DocumentClassificationFeature{MaxResults: common.Int(403),
			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("2BTEHB4NPLGVYOMVGWF7<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)
}