// 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/apigateway"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
)
func ExampleCreateDeployment() {
// 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 := apigateway.NewDeploymentClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := apigateway.CreateDeploymentRequest{CreateDeploymentDetails: apigateway.CreateDeploymentDetails{GatewayId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-gatewayId-Value"),
Locks: []apigateway.AddResourceLockDetails{apigateway.AddResourceLockDetails{Message: common.String("EXAMPLE-message-Value"),
Type: apigateway.AddResourceLockDetailsTypeFull}},
PathPrefix: common.String("EXAMPLE-pathPrefix-Value"),
Specification: &apigateway.ApiSpecification{LoggingPolicies: &apigateway.ApiSpecificationLoggingPolicies{AccessLog: &apigateway.AccessLogPolicy{IsEnabled: common.Bool(true)},
ExecutionLog: &apigateway.ExecutionLogPolicy{LogLevel: apigateway.ExecutionLogPolicyLogLevelInfo,
IsEnabled: common.Bool(false)}},
RequestPolicies: &apigateway.ApiSpecificationRequestPolicies{Authentication: apigateway.CustomAuthenticationPolicy{Parameters: map[string]string{"EXAMPLE_KEY_7UnL6": "EXAMPLE_VALUE_nVUdzpzvAey0UuQH2f8o"},
TokenHeader: common.String("EXAMPLE-tokenHeader-Value"),
TokenQueryParam: common.String("EXAMPLE-tokenQueryParam-Value"),
ValidationFailurePolicy: apigateway.ModifyResponseValidationFailurePolicy{ResponseCode: common.String("EXAMPLE-responseCode-Value"),
ResponseHeaderTransformations: &apigateway.HeaderTransformationPolicy{FilterHeaders: &apigateway.FilterHeaderPolicy{Items: []apigateway.FilterHeaderPolicyItem{apigateway.FilterHeaderPolicyItem{Name: common.String("EXAMPLE-name-Value")}}},
RenameHeaders: &apigateway.RenameHeaderPolicy{Items: []apigateway.RenameHeaderPolicyItem{apigateway.RenameHeaderPolicyItem{From: common.String("EXAMPLE-from-Value"),
To: common.String("EXAMPLE-to-Value")}}},
SetHeaders: &apigateway.SetHeaderPolicy{Items: []apigateway.SetHeaderPolicyItem{apigateway.SetHeaderPolicyItem{IfExists: apigateway.SetHeaderPolicyItemIfExistsAppend,
Name: common.String("EXAMPLE-name-Value"),
Values: []string{"EXAMPLE--Value"}}}}},
ResponseMessage: common.String("EXAMPLE-responseMessage-Value")},
CacheKey: []string{"EXAMPLE--Value"},
FunctionId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-functionId-Value"),
IsAnonymousAccessAllowed: common.Bool(true)},
Cors: &apigateway.CorsPolicy{AllowedOrigins: []string{"EXAMPLE--Value"},
ExposedHeaders: []string{"EXAMPLE--Value"},
IsAllowCredentialsEnabled: common.Bool(true),
MaxAgeInSeconds: common.Int(780),
AllowedHeaders: []string{"EXAMPLE--Value"},
AllowedMethods: []string{"EXAMPLE--Value"}},
DynamicAuthentication: &apigateway.DynamicAuthenticationPolicy{AuthenticationServers: []apigateway.AuthenticationServerPolicy{apigateway.AuthenticationServerPolicy{AuthenticationServerDetail: apigateway.TokenAuthenticationPolicy{TokenQueryParam: common.String("EXAMPLE-tokenQueryParam-Value"),
ValidationFailurePolicy: apigateway.OAuth2ResponseValidationFailurePolicy{ClientDetails: apigateway.ValidationBlockClientAppDetails{},
ResponseType: apigateway.OAuth2ResponseValidationFailurePolicyResponseTypeCode,
Scopes: []string{"EXAMPLE--Value"},
UsePkce: common.Bool(true),
FallbackRedirectPath: common.String("EXAMPLE-fallbackRedirectPath-Value"),
LogoutPath: common.String("EXAMPLE-logoutPath-Value"),
MaxExpiryDurationInHours: common.Int(7),
SourceUriDetails: apigateway.DiscoveryUriSourceUriDetails{Uri: common.String("EXAMPLE-uri-Value")},
UseCookiesForIntermediateSteps: common.Bool(false),
UseCookiesForSession: common.Bool(false)},
ValidationPolicy: apigateway.TokenAuthenticationRemoteDiscoveryValidationPolicy{AdditionalValidationPolicy: &apigateway.AdditionalValidationPolicy{VerifyClaims: []apigateway.JsonWebTokenClaim{apigateway.JsonWebTokenClaim{IsRequired: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Values: []string{"EXAMPLE--Value"}}},
Audiences: []string{"EXAMPLE--Value"},
Issuers: []string{"EXAMPLE--Value"}},
ClientDetails: apigateway.ValidationBlockClientAppDetails{},
IsSslVerifyDisabled: common.Bool(true),
MaxCacheDurationInHours: common.Int(12),
SourceUriDetails: apigateway.DiscoveryUriSourceUriDetails{Uri: common.String("EXAMPLE-uri-Value")}},
IsAnonymousAccessAllowed: common.Bool(false),
MaxClockSkewInSeconds: common.Float32(13.853617),
TokenAuthScheme: common.String("EXAMPLE-tokenAuthScheme-Value"),
TokenHeader: common.String("EXAMPLE-tokenHeader-Value")},
Key: apigateway.WildcardSelectionKey{Expression: common.String("EXAMPLE-expression-Value"),
IsDefault: common.Bool(false),
Name: common.String("EXAMPLE-name-Value")}}},
SelectionSource: apigateway.SingleSelectionSourcePolicy{Selector: common.String("EXAMPLE-selector-Value")}},
MutualTls: &apigateway.MutualTlsDetails{AllowedSans: []string{"EXAMPLE--Value"},
IsVerifiedCertificateRequired: common.Bool(false)},
RateLimiting: &apigateway.RateLimitingPolicy{RateInRequestsPerSecond: common.Int(4),
RateKey: apigateway.RateLimitingPolicyRateKeyClientIp},
UsagePlans: &apigateway.UsagePlansPolicy{TokenLocations: []string{"EXAMPLE--Value"}}},
Routes: []apigateway.ApiSpecificationRoute{apigateway.ApiSpecificationRoute{RequestPolicies: &apigateway.ApiSpecificationRouteRequestPolicies{BodyValidation: &apigateway.BodyValidationRequestPolicy{Content: map[string]apigateway.ContentValidation{"EXAMPLE_KEY_TA3VZ": apigateway.NoContentValidation{}},
Required: common.Bool(true),
ValidationMode: apigateway.BodyValidationRequestPolicyValidationModePermissive},
Cors: &apigateway.CorsPolicy{AllowedHeaders: []string{"EXAMPLE--Value"},
AllowedMethods: []string{"EXAMPLE--Value"},
AllowedOrigins: []string{"EXAMPLE--Value"},
ExposedHeaders: []string{"EXAMPLE--Value"},
IsAllowCredentialsEnabled: common.Bool(false),
MaxAgeInSeconds: common.Int(999)},
HeaderTransformations: &apigateway.HeaderTransformationPolicy{FilterHeaders: &apigateway.FilterHeaderPolicy{Items: []apigateway.FilterHeaderPolicyItem{apigateway.FilterHeaderPolicyItem{Name: common.String("EXAMPLE-name-Value")}},
Type: apigateway.FilterHeaderPolicyTypeAllow},
RenameHeaders: &apigateway.RenameHeaderPolicy{Items: []apigateway.RenameHeaderPolicyItem{apigateway.RenameHeaderPolicyItem{From: common.String("EXAMPLE-from-Value"),
To: common.String("EXAMPLE-to-Value")}}},
SetHeaders: &apigateway.SetHeaderPolicy{Items: []apigateway.SetHeaderPolicyItem{apigateway.SetHeaderPolicyItem{IfExists: apigateway.SetHeaderPolicyItemIfExistsAppend,
Name: common.String("EXAMPLE-name-Value"),
Values: []string{"EXAMPLE--Value"}}}}},
HeaderValidations: &apigateway.HeaderValidationRequestPolicy{Headers: []apigateway.HeaderValidationItem{apigateway.HeaderValidationItem{Name: common.String("EXAMPLE-name-Value"),
Required: common.Bool(false)}},
ValidationMode: apigateway.HeaderValidationRequestPolicyValidationModeEnforcing},
QueryParameterTransformations: &apigateway.QueryParameterTransformationPolicy{RenameQueryParameters: &apigateway.RenameQueryParameterPolicy{Items: []apigateway.RenameQueryParameterPolicyItem{apigateway.RenameQueryParameterPolicyItem{From: common.String("EXAMPLE-from-Value"),
To: common.String("EXAMPLE-to-Value")}}},
SetQueryParameters: &apigateway.SetQueryParameterPolicy{Items: []apigateway.SetQueryParameterPolicyItem{apigateway.SetQueryParameterPolicyItem{IfExists: apigateway.SetQueryParameterPolicyItemIfExistsOverwrite,
Name: common.String("EXAMPLE-name-Value"),
Values: []string{"EXAMPLE--Value"}}}},
FilterQueryParameters: &apigateway.FilterQueryParameterPolicy{Items: []apigateway.FilterQueryParameterPolicyItem{apigateway.FilterQueryParameterPolicyItem{Name: common.String("EXAMPLE-name-Value")}},
Type: apigateway.FilterQueryParameterPolicyTypeBlock}},
QueryParameterValidations: &apigateway.QueryParameterValidationRequestPolicy{ValidationMode: apigateway.QueryParameterValidationRequestPolicyValidationModeEnforcing,
Parameters: []apigateway.QueryParameterValidationItem{apigateway.QueryParameterValidationItem{Name: common.String("EXAMPLE-name-Value"),
Required: common.Bool(false)}}},
ResponseCacheLookup: apigateway.SimpleLookupPolicy{CacheKeyAdditions: []string{"EXAMPLE--Value"},
IsEnabled: common.Bool(false),
IsPrivateCachingEnabled: common.Bool(true)},
Authorization: apigateway.AuthenticationOnlyRouteAuthorizationPolicy{}},
ResponsePolicies: &apigateway.ApiSpecificationRouteResponsePolicies{HeaderTransformations: &apigateway.HeaderTransformationPolicy{RenameHeaders: &apigateway.RenameHeaderPolicy{Items: []apigateway.RenameHeaderPolicyItem{apigateway.RenameHeaderPolicyItem{From: common.String("EXAMPLE-from-Value"),
To: common.String("EXAMPLE-to-Value")}}},
SetHeaders: &apigateway.SetHeaderPolicy{Items: []apigateway.SetHeaderPolicyItem{apigateway.SetHeaderPolicyItem{IfExists: apigateway.SetHeaderPolicyItemIfExistsOverwrite,
Name: common.String("EXAMPLE-name-Value"),
Values: []string{"EXAMPLE--Value"}}}},
FilterHeaders: &apigateway.FilterHeaderPolicy{Type: apigateway.FilterHeaderPolicyTypeAllow,
Items: []apigateway.FilterHeaderPolicyItem{apigateway.FilterHeaderPolicyItem{Name: common.String("EXAMPLE-name-Value")}}}},
ResponseCacheStore: apigateway.FixedTtlResponseCacheStorePolicy{TimeToLiveInSeconds: common.Int(447)}},
Backend: apigateway.OracleFunctionBackend{FunctionId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-functionId-Value")},
LoggingPolicies: &apigateway.ApiSpecificationLoggingPolicies{AccessLog: &apigateway.AccessLogPolicy{IsEnabled: common.Bool(false)},
ExecutionLog: &apigateway.ExecutionLogPolicy{IsEnabled: common.Bool(false),
LogLevel: apigateway.ExecutionLogPolicyLogLevelError}},
Methods: []apigateway.ApiSpecificationRouteMethodsEnum{apigateway.ApiSpecificationRouteMethodsPut},
Path: common.String("EXAMPLE-path-Value")}}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_hARCR": map[string]interface{}{"EXAMPLE_KEY_kt8I9": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_RT6N3": "EXAMPLE_VALUE_lxdW5sdKxHuSC2oQ1iI1"}},
OpcRequestId: common.String("M4YR42M4ZNK6NFQ7ULIZ<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateDeployment(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}