// 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{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("SGGLhouKwVMBScF1HZME"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypeBankStatement,
		Features: []aidocument.DocumentFeature{aidocument.DocumentClassificationFeature{MaxResults: common.Int(577),
			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"),
		OcrData: &aidocument.AnalyzeDocumentResult{DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
			PageCount: common.Int(755)},
			Pages: []aidocument.Page{aidocument.Page{DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.70111716),
				Language: common.String("EXAMPLE-language-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(9058.35),
					Unit:  aidocument.DimensionsUnitInch,
					Width: common.Float64(9476.382)},
				PageNumber: common.Int(751),
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{Confidence: common.Float32(0.49491704),
					State: aidocument.SelectionMarkStateUnselected,
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.48811555),
						Y: common.Float64(0.77463)}}}}},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.51606256),
					Y: common.Float64(0.7134767)}}},
					Confidence: common.Float32(0.19839245)}},
				Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.06136483),
					Y: common.Float64(0.8453009)}}},
					Confidence: common.Float32(0.1852023),
					Text:       common.String("EXAMPLE-text-Value")}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.27862382),
					DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
					DocumentType: common.String("EXAMPLE-documentType-Value")}},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldName: &aidocument.FieldName{Name: common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{927},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.61571825),
						Y: common.Float64(0.493146)}}},
					Confidence: common.Float32(0.9464296)},
					FieldType: aidocument.DocumentFieldFieldTypeLineItem,
					FieldValue: aidocument.ValuePhoneNumber{Text: common.String("EXAMPLE-text-Value"),
						Value:       common.String("EXAMPLE-value-Value"),
						WordIndexes: []int{793},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.22640842),
							Y: common.Float64(0.43084896)}}},
						Confidence:           common.Float32(0.24744278),
						NormalizedConfidence: common.Float32(0.6887123),
						NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value")},
					FieldLabel: &aidocument.FieldLabel{Name: common.String("EXAMPLE-name-Value"),
						Confidence: common.Float32(0.8690598)}}},
				Lines: []aidocument.Line{aidocument.Line{Text: common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{789},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.81444204),
						Y: common.Float64(0.04667318)}}},
					Confidence: common.Float32(0.8138433)}},
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7596075),
					Y: common.Float64(0.7179757)}}},
					ColumnCount: common.Int(101),
					Confidence:  common.Float32(0.31600523),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{RowIndex: common.Int(279),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{719},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.24262589),
							Y: common.Float64(0.4627477)}}},
						ColumnIndex: common.Int(438),
						Confidence:  common.Float32(0.7697154)}}}},
					RowCount: common.Int(686)}},
				BarCodes: []aidocument.BarCode{aidocument.BarCode{Confidence: common.Float32(0.98994696),
					Value: common.String("EXAMPLE-value-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.10585737),
						Y: common.Float64(0.24653745)}}},
					CodeType: common.String("EXAMPLE-codeType-Value")}}}},
			SearchablePdf:                 []byte("UBwEsccU3IDshZgLGi0a"),
			TableExtractionModelVersion:   common.String("EXAMPLE-tableExtractionModelVersion-Value"),
			BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
				Confidence: common.Float32(0.17152697),
				DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")}},
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			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"),
			SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TextExtractionModelVersion:         common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.7799864),
				Language: common.String("EXAMPLE-language-Value")}}}},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("ILYJ7ALH9WCS8HUHG7RV<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)
}