コード例 #1
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_Predict() {
	svc := machinelearning.New(nil)

	params := &machinelearning.PredictInput{
		MLModelID:       aws.String("EntityId"), // Required
		PredictEndpoint: aws.String("VipURL"),   // Required
		Record: map[string]*string{ // Required
			"Key": aws.String("VariableValue"), // Required
			// More values...
		},
	}
	resp, err := svc.Predict(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #2
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_UpdateMLModel() {
	svc := machinelearning.New(nil)

	params := &machinelearning.UpdateMLModelInput{
		MLModelID:      aws.String("EntityId"), // Required
		MLModelName:    aws.String("EntityName"),
		ScoreThreshold: aws.Float64(1.0),
	}
	resp, err := svc.UpdateMLModel(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #3
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_CreateMLModel() {
	svc := machinelearning.New(nil)

	params := &machinelearning.CreateMLModelInput{
		MLModelID:            aws.String("EntityId"),    // Required
		MLModelType:          aws.String("MLModelType"), // Required
		TrainingDataSourceID: aws.String("EntityId"),    // Required
		MLModelName:          aws.String("EntityName"),
		Parameters: map[string]*string{
			"Key": aws.String("StringType"), // Required
			// More values...
		},
		Recipe:    aws.String("Recipe"),
		RecipeURI: aws.String("S3Url"),
	}
	resp, err := svc.CreateMLModel(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #4
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_CreateDataSourceFromS3() {
	svc := machinelearning.New(nil)

	params := &machinelearning.CreateDataSourceFromS3Input{
		DataSourceID: aws.String("EntityId"), // Required
		DataSpec: &machinelearning.S3DataSpec{ // Required
			DataLocationS3:       aws.String("S3Url"), // Required
			DataRearrangement:    aws.String("DataRearrangement"),
			DataSchema:           aws.String("DataSchema"),
			DataSchemaLocationS3: aws.String("S3Url"),
		},
		ComputeStatistics: aws.Bool(true),
		DataSourceName:    aws.String("EntityName"),
	}
	resp, err := svc.CreateDataSourceFromS3(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #5
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_CreateDataSourceFromRDS() {
	svc := machinelearning.New(nil)

	params := &machinelearning.CreateDataSourceFromRDSInput{
		DataSourceID: aws.String("EntityId"), // Required
		RDSData: &machinelearning.RDSDataSpec{ // Required
			DatabaseCredentials: &machinelearning.RDSDatabaseCredentials{ // Required
				Password: aws.String("RDSDatabasePassword"), // Required
				Username: aws.String("RDSDatabaseUsername"), // Required
			},
			DatabaseInformation: &machinelearning.RDSDatabase{ // Required
				DatabaseName:       aws.String("RDSDatabaseName"),       // Required
				InstanceIdentifier: aws.String("RDSInstanceIdentifier"), // Required
			},
			ResourceRole:      aws.String("EDPResourceRole"), // Required
			S3StagingLocation: aws.String("S3Url"),           // Required
			SecurityGroupIDs: []*string{ // Required
				aws.String("EDPSecurityGroupId"), // Required
				// More values...
			},
			SelectSQLQuery:    aws.String("RDSSelectSqlQuery"), // Required
			ServiceRole:       aws.String("EDPServiceRole"),    // Required
			SubnetID:          aws.String("EDPSubnetId"),       // Required
			DataRearrangement: aws.String("DataRearrangement"),
			DataSchema:        aws.String("DataSchema"),
			DataSchemaURI:     aws.String("S3Url"),
		},
		RoleARN:           aws.String("RoleARN"), // Required
		ComputeStatistics: aws.Bool(true),
		DataSourceName:    aws.String("EntityName"),
	}
	resp, err := svc.CreateDataSourceFromRDS(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #6
0
func TestPredictEndpoint(t *testing.T) {
	ml := machinelearning.New(nil)
	ml.Handlers.Send.Clear()
	ml.Handlers.Send.PushBack(func(r *aws.Request) {
		r.HTTPResponse = &http.Response{
			StatusCode: 200,
			Header:     http.Header{},
			Body:       ioutil.NopCloser(bytes.NewReader([]byte("{}"))),
		}
	})

	req, _ := ml.PredictRequest(&machinelearning.PredictInput{
		PredictEndpoint: aws.String("https://localhost/endpoint"),
		MLModelID:       aws.String("id"),
		Record:          map[string]*string{},
	})
	err := req.Send()

	assert.Nil(t, err)
	assert.Equal(t, "https://localhost/endpoint", req.HTTPRequest.URL.String())
}
コード例 #7
0
ファイル: examples_test.go プロジェクト: gunosy/aws-sdk-go
func ExampleMachineLearning_DescribeMLModels() {
	svc := machinelearning.New(nil)

	params := &machinelearning.DescribeMLModelsInput{
		EQ:             aws.String("ComparatorValue"),
		FilterVariable: aws.String("MLModelFilterVariable"),
		GE:             aws.String("ComparatorValue"),
		GT:             aws.String("ComparatorValue"),
		LE:             aws.String("ComparatorValue"),
		LT:             aws.String("ComparatorValue"),
		Limit:          aws.Int64(1),
		NE:             aws.String("ComparatorValue"),
		NextToken:      aws.String("StringType"),
		Prefix:         aws.String("ComparatorValue"),
		SortOrder:      aws.String("SortOrder"),
	}
	resp, err := svc.DescribeMLModels(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
コード例 #8
0
ファイル: client.go プロジェクト: gunosy/aws-sdk-go
func init() {
	Before("@machinelearning", func() {
		World["client"] = machinelearning.New(nil)
	})
}
コード例 #9
0
ファイル: interface_test.go プロジェクト: gunosy/aws-sdk-go
func TestInterface(t *testing.T) {
	assert.Implements(t, (*machinelearningiface.MachineLearningAPI)(nil), machinelearning.New(nil))
}