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

	"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{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		Document: aidocument.InlineDocumentDetails{Data: []byte("pgDWu90EiVeVNs9uGE5H"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypePayslip,
		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{DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
			PageCount: common.Int(921)},
			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{CodeType: common.String("EXAMPLE-codeType-Value"),
				Confidence: common.Float32(0.9311609),
				Value:      common.String("EXAMPLE-value-Value"),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.05867535),
					Y: common.Float64(0.44432253)}}}}},
				DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.34501714),
					Language: common.String("EXAMPLE-language-Value")}},
				DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.5289005),
					Name: common.String("EXAMPLE-name-Value")},
					FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.571634),
						Y: common.Float64(0.74919754)}}},
						Confidence:  common.Float32(0.7253601),
						Name:        common.String("EXAMPLE-name-Value"),
						WordIndexes: []int{192}},
					FieldType: aidocument.DocumentFieldFieldTypeLineItem,
					FieldValue: aidocument.ValueDate{NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
						Text:        common.String("EXAMPLE-text-Value"),
						Value:       &common.SDKTime{Time: time.Now()},
						WordIndexes: []int{862},
						BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.36996943),
							Y: common.Float64(0.82883954)}}},
						Confidence:           common.Float32(0.50920236),
						NormalizedConfidence: common.Float32(0.67663234)}}},
				SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{Confidence: common.Float32(0.12940931),
					State: aidocument.SelectionMarkStateSelected,
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6239295),
						Y: common.Float64(0.31811917)}}}}},
				Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.17849636),
					Y: common.Float64(0.83037513)}}},
					Confidence: common.Float32(0.81502527)}},
				Tables: []aidocument.Table{aidocument.Table{ColumnCount: common.Int(417),
					Confidence: common.Float32(0.7567968),
					HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.20636326),
						Y: common.Float64(0.9804424)}}},
						ColumnIndex: common.Int(931),
						Confidence:  common.Float32(0.9510738),
						RowIndex:    common.Int(817),
						Text:        common.String("EXAMPLE-text-Value"),
						WordIndexes: []int{110}}}}},
					RowCount: common.Int(244),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.2521472),
						X: common.Float64(0.16993767)}}}}},
				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.57072455)}},
				Dimensions: &aidocument.Dimensions{Height: common.Float64(9824.681),
					Unit:  aidocument.DimensionsUnitPixel,
					Width: common.Float64(3369.32)},
				Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.045131147),
					Y: common.Float64(0.4193164)}}},
					Confidence:  common.Float32(0.339808),
					Text:        common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{919}}},
				PageNumber: common.Int(64),
				Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.9973894),
					Text: common.String("EXAMPLE-text-Value"),
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.50961673),
						Y: common.Float64(0.80474406)}}}}}}},
			SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
			BarCodeExtractionModelVersion:      common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
			DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
			KeyValueExtractionModelVersion:     common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
			SearchablePdf:                      []byte("jm7p3TNVDMJ4m2NfDwbn"),
			TableExtractionModelVersion:        common.String("EXAMPLE-tableExtractionModelVersion-Value"),
			TextExtractionModelVersion:         common.String("EXAMPLE-textExtractionModelVersion-Value"),
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.53643167),
				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.053895116),
				Language: common.String("EXAMPLE-language-Value")}}},
		OutputLocation: &aidocument.OutputLocation{NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			Prefix:     common.String("EXAMPLE-prefix-Value"),
			BucketName: common.String("EXAMPLE-bucketName-Value")}},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("J1GBG1IXHDZMNREAKWJS<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)
}