// 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{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.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{LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
			Pages: []aidocument.Page{aidocument.Page{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{Y: common.Float64(0.4454499),
					X: common.Float64(0.29512691)}}}}},
				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")}},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Name: common.String("EXAMPLE-name-Value"),
					Confidence: common.Float32(0.91329247)},
					FieldName: &aidocument.FieldName{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"),
						WordIndexes: []int{808}},
					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{Y: common.Float64(0.15085089),
							X: common.Float64(0.5485146)}}}}}},
				Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.16880095),
					Y: common.Float64(0.56655943)}}},
					Confidence:  common.Float32(0.2596383),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{597}}},
				PageNumber: common.Int(899),
				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}},
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.90452045),
					Y: common.Float64(0.360969)}}},
					ColumnCount: common.Int(528),
					Confidence:  common.Float32(0.8949226),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{RowIndex: common.Int(82),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{470},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.21344054),
							Y: common.Float64(0.18217057)}}},
						ColumnIndex: common.Int(97),
						Confidence:  common.Float32(0.7915788)}}}},
					RowCount: common.Int(481)}},
				Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.539),
					Y: common.Float64(0.18517375)}}},
					Confidence: common.Float32(0.5820554),
					Text:       common.String("EXAMPLE-text-Value")}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.7630292),
					Language: common.String("EXAMPLE-language-Value")}},
				Dimensions: &aidocument.Dimensions{Width: common.Float64(2736.696),
					Height: common.Float64(7404.4033),
					Unit:   aidocument.DimensionsUnitInch},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.976919),
					Y: common.Float64(0.36215204)}}},
					Confidence: common.Float32(0.9114065)}}}},
			SearchablePdf:                   []byte("Cjy3B5kA4kdtquMhVkoV"),
			SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Language: common.String("EXAMPLE-language-Value"),
				Confidence: common.Float32(0.88962764)}},
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
				Message: common.String("EXAMPLE-message-Value")}},
			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.8591421),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}},
			DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
				PageCount: common.Int(286)},
			KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value")},
		OutputLocation: &aidocument.OutputLocation{BucketName: common.String("EXAMPLE-bucketName-Value"),
			NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			Prefix:        common.String("EXAMPLE-prefix-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)
}