// 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{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{BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			KeyValueExtractionModelVersion:     common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
			SearchablePdf:                      []byte("8cxK8ee5ezTzNah6vDVl"),
			SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			TextExtractionModelVersion:         common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value"),
				Confidence:   common.Float32(0.7323872)}},
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.3057726),
				Language: common.String("EXAMPLE-language-Value")}},
			DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
				PageCount: common.Int(833)},
			Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
				Message: common.String("EXAMPLE-message-Value")}},
			LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
			Pages: []aidocument.Page{aidocument.Page{BarCodes: []aidocument.BarCode{aidocument.BarCode{Value: common.String("EXAMPLE-value-Value"),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.4474274),
					Y: common.Float64(0.14955759)}}},
				CodeType:   common.String("EXAMPLE-codeType-Value"),
				Confidence: common.Float32(0.038740635)}},
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.31349844),
					DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
					DocumentType: common.String("EXAMPLE-documentType-Value")}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.6068976),
					Language: common.String("EXAMPLE-language-Value")}},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldValue: aidocument.ValueArray{WordIndexes: []int{803},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.80285674),
						Y: common.Float64(0.43211836)}}},
					Confidence:           common.Float32(0.5438604),
					NormalizedConfidence: common.Float32(0.6725511),
					NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value"),
					Text:                 common.String("EXAMPLE-text-Value")},
					FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.030065954),
						Name: common.String("EXAMPLE-name-Value")},
					FieldName: &aidocument.FieldName{Name: common.String("EXAMPLE-name-Value"),
						WordIndexes: []int{77},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.23701948),
							Y: common.Float64(0.7572835)}}},
						Confidence: common.Float32(0.40056372)},
					FieldType: aidocument.DocumentFieldFieldTypeLineItemGroup}},
				Lines: []aidocument.Line{aidocument.Line{Confidence: common.Float32(0.8147919),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{885},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.11534929),
						Y: common.Float64(0.7190623)}}}}},
				PageNumber: common.Int(950),
				Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.44233435),
					Y: common.Float64(0.82514185)}}},
					ColumnCount: common.Int(993),
					Confidence:  common.Float32(0.70735866),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.14207178),
						Y: common.Float64(0.68579)}}},
						ColumnIndex: common.Int(367),
						Confidence:  common.Float32(0.41888177),
						RowIndex:    common.Int(531),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{626}}}}},
					RowCount: common.Int(111)}},
				Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.048840165),
					Y: common.Float64(0.6227809)}}},
					Confidence: common.Float32(0.18583578),
					Text:       common.String("EXAMPLE-text-Value")}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(6997.5396),
					Unit:  aidocument.DimensionsUnitPixel,
					Width: common.Float64(672.36426)},
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.031799674),
					Y: common.Float64(0.96926)}}},
					Confidence: common.Float32(0.6061945),
					State:      aidocument.SelectionMarkStateUnselected}},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.31731308),
					Y: common.Float64(0.24632692)}}},
					Confidence: common.Float32(0.3541156)}}}},
			TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-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"),
		Document: aidocument.InlineDocumentDetails{Data: []byte("fMOOKLkdzX26YHBhThDv"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypeInvoice},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("CEVR5H6K4FYEHGKR7J09<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)
}