// 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.InlineDocumentDetails{Data: []byte("w77lGhinbM3l29jIyu6y"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypeOthers,
		Features: []aidocument.DocumentFeature{aidocument.DocumentKeyValueExtractionFeature{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{DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.5007388),
			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(811)},
			SearchablePdf:                   []byte("eXVtf3EFDhkF7FVLrn0P"),
			SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TableExtractionModelVersion:     common.String("EXAMPLE-tableExtractionModelVersion-Value"),
			TextExtractionModelVersion:      common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Language: common.String("EXAMPLE-language-Value"),
				Confidence: common.Float32(0.039655983)}},
			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{SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.1708327),
				Y: common.Float64(0.124837875)}}},
				Confidence: common.Float32(0.34507346),
				State:      aidocument.SelectionMarkStateSelected}},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.18621355),
					Y: common.Float64(0.97734314)}}},
					Confidence: common.Float32(0.38006175)}},
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.73039603),
					Y: common.Float64(0.8732025)}}},
					ColumnCount: common.Int(659),
					Confidence:  common.Float32(0.9825451),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{Confidence: common.Float32(0.43781954),
						RowIndex:    common.Int(394),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{215},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.91673434),
							Y: common.Float64(0.8500111)}}},
						ColumnIndex: common.Int(804)}}}},
					RowCount: common.Int(760)}},
				BarCodes: []aidocument.BarCode{aidocument.BarCode{Value: common.String("EXAMPLE-value-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.04473734),
						X: common.Float64(0.9061476)}}},
					CodeType:   common.String("EXAMPLE-codeType-Value"),
					Confidence: common.Float32(0.92836213)}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
					Confidence: common.Float32(0.14713478),
					DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.81087387),
					Language: common.String("EXAMPLE-language-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(1256.7782),
					Unit:  aidocument.DimensionsUnitInch,
					Width: common.Float64(4004.5256)},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.23760694),
					Y: common.Float64(0.30109823)}}},
					Confidence:  common.Float32(0.43582314),
					Name:        common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{150}},
					FieldType: aidocument.DocumentFieldFieldTypeLineItem,
					FieldValue: aidocument.ValueInteger{WordIndexes: []int{374},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.065181255),
							Y: common.Float64(0.9004876)}}},
						Confidence:           common.Float32(0.7934123),
						NormalizedConfidence: common.Float32(0.1402086),
						NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value"),
						Text:                 common.String("EXAMPLE-text-Value"),
						Value:                common.Int(72)},
					FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.26290357),
						Name: common.String("EXAMPLE-name-Value")}}},
				Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.23141193),
					Y: common.Float64(0.53373486)}}},
					Confidence: common.Float32(0.9049306),
					Text:       common.String("EXAMPLE-text-Value")}},
				Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.02838248),
					Y: common.Float64(0.5173472)}}},
					Confidence:  common.Float32(0.15109724),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{424}}},
				PageNumber: common.Int(807)}},
			BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value")}},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("3DNDWQEGSLBLPGW07QA6<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)
}