// 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{Document: aidocument.InlineDocumentDetails{Data: []byte("4hUtcQaXDvX387sWVcmR"),
		PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypePassport,
		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{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{Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.91702473),
				Text: common.String("EXAMPLE-text-Value"),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9935627),
					Y: common.Float64(0.16390628)}}}}},
				BarCodes: []aidocument.BarCode{aidocument.BarCode{CodeType: common.String("EXAMPLE-codeType-Value"),
					Confidence: common.Float32(0.77086824),
					Value:      common.String("EXAMPLE-value-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.65454686),
						Y: common.Float64(0.9701144)}}}}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.9435228),
					Language: common.String("EXAMPLE-language-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(4959.847),
					Unit:  aidocument.DimensionsUnitInch,
					Width: common.Float64(5384.74)},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.1622389),
					Name: common.String("EXAMPLE-name-Value")},
					FieldName: &aidocument.FieldName{Name: common.String("EXAMPLE-name-Value"),
						WordIndexes: []int{106},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5552317),
							Y: common.Float64(0.2690071)}}},
						Confidence: common.Float32(0.33730292)},
					FieldType: aidocument.DocumentFieldFieldTypeKeyValue,
					FieldValue: aidocument.ValueString{Value: common.String("EXAMPLE-value-Value"),
						WordIndexes: []int{591},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.30213982),
							X: common.Float64(0.41557562)}}},
						Confidence:           common.Float32(0.5518287),
						NormalizedConfidence: common.Float32(0.025857389),
						NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value"),
						Text:                 common.String("EXAMPLE-text-Value")}}},
				Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.63630563),
					Y: common.Float64(0.6410271)}}},
					Confidence:  common.Float32(0.06763345),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{126}}},
				PageNumber: common.Int(456),
				Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.7075796),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.3521831),
						Y: common.Float64(0.060491383)}}}}},
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.91816366),
					Y: common.Float64(0.9762113)}}},
					ColumnCount: common.Int(602),
					Confidence:  common.Float32(0.8217945),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.90631664),
						Y: common.Float64(0.34574497)}}},
						ColumnIndex: common.Int(688),
						Confidence:  common.Float32(0.15351987),
						RowIndex:    common.Int(128),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{757}}}}},
					RowCount: common.Int(629)}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
					Confidence: common.Float32(0.2476762),
					DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")}},
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8811885),
					Y: common.Float64(0.56706506)}}},
					Confidence: common.Float32(0.54035455),
					State:      aidocument.SelectionMarkStateSelected}}}},
			TableExtractionModelVersion:   common.String("EXAMPLE-tableExtractionModelVersion-Value"),
			BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Language: common.String("EXAMPLE-language-Value"),
				Confidence: common.Float32(0.1931243)}},
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
				PageCount: common.Int(242)},
			SearchablePdf:                   []byte("G7WiCaIQhwA6w4XZFv8l"),
			SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TextExtractionModelVersion:      common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.16307533),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}}},
		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")},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("LBGV6KJQUDQVXAB8RVZF<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)
}