1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
// Code generated by smithy-go-codegen DO NOT EDIT.
package sagemaker
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/service/sagemaker/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates a model in SageMaker. In the request, you name the model and describe a
// primary container. For the primary container, you specify the Docker image that
// contains inference code, artifacts (from prior training), and a custom
// environment map that the inference code uses when you deploy the model for
// predictions. Use this API to create a model if you want to use SageMaker hosting
// services or run a batch transform job. To host your model, you create an
// endpoint configuration with the CreateEndpointConfig API, and then create an
// endpoint with the CreateEndpoint API. SageMaker then deploys all of the
// containers that you defined for the model in the hosting environment. For an
// example that calls this method when deploying a model to SageMaker hosting
// services, see Create a Model (Amazon Web Services SDK for Python (Boto 3)). (https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-deployment.html#realtime-endpoints-deployment-create-model)
// To run a batch transform using your model, you start a job with the
// CreateTransformJob API. SageMaker uses your model and your dataset to get
// inferences which are then saved to a specified S3 location. In the request, you
// also provide an IAM role that SageMaker can assume to access model artifacts and
// docker image for deployment on ML compute hosting instances or for batch
// transform jobs. In addition, you also use the IAM role to manage permissions the
// inference code needs. For example, if the inference code access any other Amazon
// Web Services resources, you grant necessary permissions via this role.
func (c *Client) CreateModel(ctx context.Context, params *CreateModelInput, optFns ...func(*Options)) (*CreateModelOutput, error) {
if params == nil {
params = &CreateModelInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateModel", params, optFns, c.addOperationCreateModelMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateModelOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateModelInput struct {
// The name of the new model.
//
// This member is required.
ModelName *string
// Specifies the containers in the inference pipeline.
Containers []types.ContainerDefinition
// Isolates the model container. No inbound or outbound network calls can be made
// to or from the model container.
EnableNetworkIsolation *bool
// The Amazon Resource Name (ARN) of the IAM role that SageMaker can assume to
// access model artifacts and docker image for deployment on ML compute instances
// or for batch transform jobs. Deploying on ML compute instances is part of model
// hosting. For more information, see SageMaker Roles (https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html)
// . To be able to pass this role to SageMaker, the caller of this API must have
// the iam:PassRole permission.
ExecutionRoleArn *string
// Specifies details of how containers in a multi-container endpoint are called.
InferenceExecutionConfig *types.InferenceExecutionConfig
// The location of the primary docker image containing inference code, associated
// artifacts, and custom environment map that the inference code uses when the
// model is deployed for predictions.
PrimaryContainer *types.ContainerDefinition
// An array of key-value pairs. You can use tags to categorize your Amazon Web
// Services resources in different ways, for example, by purpose, owner, or
// environment. For more information, see Tagging Amazon Web Services Resources (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html)
// .
Tags []types.Tag
// A VpcConfig (https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_VpcConfig.html)
// object that specifies the VPC that you want your model to connect to. Control
// access to and from your model container by configuring the VPC. VpcConfig is
// used in hosting services and in batch transform. For more information, see
// Protect Endpoints by Using an Amazon Virtual Private Cloud (https://docs.aws.amazon.com/sagemaker/latest/dg/host-vpc.html)
// and Protect Data in Batch Transform Jobs by Using an Amazon Virtual Private
// Cloud (https://docs.aws.amazon.com/sagemaker/latest/dg/batch-vpc.html) .
VpcConfig *types.VpcConfig
noSmithyDocumentSerde
}
type CreateModelOutput struct {
// The ARN of the model created in SageMaker.
//
// This member is required.
ModelArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateModelMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateModel{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateModel{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateModel"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
return err
}
if err = addRetryMiddlewares(stack, options); err != nil {
return err
}
if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
return err
}
if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpCreateModelValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateModel(options.Region), middleware.Before); err != nil {
return err
}
if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateModel(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "CreateModel",
}
}
|