// 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{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.ObjectStorageDocumentDetails{ObjectName: common.String("EXAMPLE-objectName-Value"),
			PageRange:     []string{"EXAMPLE--Value"},
			BucketName:    common.String("EXAMPLE-bucketName-Value"),
			NamespaceName: common.String("EXAMPLE-namespaceName-Value")},
		DocumentType: aidocument.DocumentTypeBankStatement,
		Features:     []aidocument.DocumentFeature{aidocument.DocumentElementsExtractionFeature{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")}},
		Language:     common.String("EXAMPLE-language-Value"),
		OcrData: &aidocument.AnalyzeDocumentResult{BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.8591421),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}},
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
				PageCount: common.Int(286)},
			KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
			Pages: []aidocument.Page{aidocument.Page{DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.91329247),
				Name: common.String("EXAMPLE-name-Value")},
				FieldName: &aidocument.FieldName{WordIndexes: []int{808},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8225719),
						Y: common.Float64(0.22518373)}}},
					Confidence: common.Float32(0.48671412),
					Name:       common.String("EXAMPLE-name-Value")},
				FieldType: aidocument.DocumentFieldFieldTypeLineItemGroup,
				FieldValue: aidocument.ValueDate{Confidence: common.Float32(0.50700265),
					NormalizedConfidence: common.Float32(0.7296643),
					NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value"),
					Text:                 common.String("EXAMPLE-text-Value"),
					Value:                &common.SDKTime{Time: time.Now()},
					WordIndexes:          []int{585},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5485146),
						Y: common.Float64(0.15085089)}}}}}},
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5427887),
					Y: common.Float64(0.39394003)}}},
					Confidence: common.Float32(0.47050613),
					State:      aidocument.SelectionMarkStateUnselected}},
				Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.9114065),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.36215204),
						X: common.Float64(0.976919)}}}}},
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.360969),
					X: common.Float64(0.90452045)}}},
					ColumnCount: common.Int(528),
					Confidence:  common.Float32(0.8949226),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{WordIndexes: []int{470},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.18217057),
							X: common.Float64(0.21344054)}}},
						ColumnIndex: common.Int(97),
						Confidence:  common.Float32(0.7915788),
						RowIndex:    common.Int(82),
						Text:        common.String("EXAMPLE-text-Value")}}}},
					RowCount: common.Int(481)}},
				Words: []aidocument.Word{aidocument.Word{Text: common.String("EXAMPLE-text-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.539),
						Y: common.Float64(0.18517375)}}},
					Confidence: common.Float32(0.5820554)}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.88120127),
					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.7630292),
					Language: common.String("EXAMPLE-language-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(7404.4033),
					Unit:  aidocument.DimensionsUnitInch,
					Width: common.Float64(2736.696)},
				Lines: []aidocument.Line{aidocument.Line{Confidence: common.Float32(0.2596383),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{597},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.16880095),
						Y: common.Float64(0.56655943)}}}}},
				PageNumber: common.Int(899),
				BarCodes: []aidocument.BarCode{aidocument.BarCode{CodeType: common.String("EXAMPLE-codeType-Value"),
					Confidence: common.Float32(0.18569374),
					Value:      common.String("EXAMPLE-value-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.29512691),
						Y: common.Float64(0.4454499)}}}}}}},
			TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.88962764),
				Language: common.String("EXAMPLE-language-Value")}},
			Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
				Message: common.String("EXAMPLE-message-Value")}},
			LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
			SearchablePdf:                      []byte("Cjy3B5kA4kdtquMhVkoV"),
			SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TableExtractionModelVersion:        common.String("EXAMPLE-tableExtractionModelVersion-Value")}},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("AQMB4MQPRVVSD7UCGIZB<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)
}