// 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"

	"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{Prefix: common.String("EXAMPLE-prefix-Value"),
		BucketName:    common.String("EXAMPLE-bucketName-Value"),
		NamespaceName: common.String("EXAMPLE-namespaceName-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.DocumentTypeHealthInsuranceId,
		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"),
			SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TableExtractionModelVersion:     common.String("EXAMPLE-tableExtractionModelVersion-Value"),
			TextExtractionModelVersion:      common.String("EXAMPLE-textExtractionModelVersion-Value"),
			BarCodeExtractionModelVersion:   common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.7631093),
				Language: common.String("EXAMPLE-language-Value")}},
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			KeyValueExtractionModelVersion:     common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
			Pages: []aidocument.Page{aidocument.Page{DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.16390628),
				Name: common.String("EXAMPLE-name-Value")},
				FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.6410271),
					X: common.Float64(0.63630563)}}},
					Confidence:  common.Float32(0.06763345),
					Name:        common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{126}},
				FieldType: aidocument.DocumentFieldFieldTypeKeyValue,
				FieldValue: aidocument.ValueNumber{Text: common.String("EXAMPLE-text-Value"),
					Value:       common.Float32(9170.247),
					WordIndexes: []int{841},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.56144947),
						Y: common.Float64(0.2476762)}}},
					Confidence:           common.Float32(0.49598473),
					NormalizedConfidence: common.Float32(0.9935627),
					NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value")}}},
				PageNumber: common.Int(159),
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8217945),
					Y: common.Float64(0.91816366)}}},
					Confidence: common.Float32(0.72975814),
					State:      aidocument.SelectionMarkStateUnselected}},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.16208017),
					Y: common.Float64(0.46701968)}}},
					Confidence: common.Float32(0.56479573)}},
				Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.34030187),
					Y: common.Float64(0.2273649)}}},
					Confidence: common.Float32(0.68222594),
					Text:       common.String("EXAMPLE-text-Value")}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.54962003),
					Language: common.String("EXAMPLE-language-Value")}},
				Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.073206306),
					Y: common.Float64(0.1410889)}}},
					Confidence:  common.Float32(0.58054036),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{613}}},
				Tables: []aidocument.Table{aidocument.Table{Confidence: common.Float32(0.74348044),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.42452675),
						Y: common.Float64(0.26406038)}}},
						ColumnIndex: common.Int(384),
						Confidence:  common.Float32(0.5484517),
						RowIndex:    common.Int(965),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{452}}}}},
					RowCount: common.Int(127),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.035226166),
						Y: common.Float64(0.24242514)}}},
					ColumnCount: common.Int(396)}},
				BarCodes: []aidocument.BarCode{aidocument.BarCode{CodeType: common.String("EXAMPLE-codeType-Value"),
					Confidence: common.Float32(0.8479858),
					Value:      common.String("EXAMPLE-value-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.15351987),
						Y: common.Float64(0.90631664)}}}}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.45684963),
					DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
					DocumentType: common.String("EXAMPLE-documentType-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(3779.0603),
					Unit:  aidocument.DimensionsUnitPixel,
					Width: common.Float64(8098.0933)}}},
			SearchablePdf: []byte("8UpqfCDvP1KJsn8vtSWf"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.9762113),
				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(528)},
			Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
				Message: common.String("EXAMPLE-message-Value")}}}},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("G62G7WICAIQHWA6W4XZF<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)
}