From 544c90de4c053bc0ff1a8ee767440b3a27f5a1e6 Mon Sep 17 00:00:00 2001 From: ajay-malhotra1 Date: Mon, 4 Oct 2021 12:17:09 -0700 Subject: [PATCH] feat(DirectLink): add the changes to update the BGP parameters and enable BFD config on directlink gateways --- .../direct_link_provider_v2.go | 411 +++++- ...irect_link_provider_v2_integration_test.go | 363 ++++- .../direct_link_provider_v2_suite_test.go | 2 +- .../direct_link_provider_v2_test.go | 1306 ++++++++++++++--- directlinkv1/direct_link_v1.go | 1047 ++++++++++++- .../direct_link_v1_integration_test.go | 213 ++- directlinkv1/direct_link_v1_test.go | 429 +++++- 7 files changed, 3386 insertions(+), 385 deletions(-) diff --git a/directlinkproviderv2/direct_link_provider_v2.go b/directlinkproviderv2/direct_link_provider_v2.go index 7b68f17..370bbb2 100644 --- a/directlinkproviderv2/direct_link_provider_v2.go +++ b/directlinkproviderv2/direct_link_provider_v2.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,22 @@ * limitations under the License. */ +/* + * IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156 + */ + // Package directlinkproviderv2 : Operations and models for the DirectLinkProviderV2 service package directlinkproviderv2 import ( + "context" "encoding/json" "fmt" + "net/http" "reflect" + "time" - "github.com/IBM/go-sdk-core/v4/core" + "github.com/IBM/go-sdk-core/v5/core" common "github.com/IBM/networking-go-sdk/common" "github.com/go-openapi/strfmt" ) @@ -117,24 +124,74 @@ func NewDirectLinkProviderV2(options *DirectLinkProviderV2Options) (service *Dir return } +// GetServiceURLForRegion returns the service URL to be used for the specified region +func GetServiceURLForRegion(region string) (string, error) { + return "", fmt.Errorf("service does not support regional URLs") +} + +// Clone makes a copy of "directLinkProvider" suitable for processing requests. +func (directLinkProvider *DirectLinkProviderV2) Clone() *DirectLinkProviderV2 { + if core.IsNil(directLinkProvider) { + return nil + } + clone := *directLinkProvider + clone.Service = directLinkProvider.Service.Clone() + return &clone +} + // SetServiceURL sets the service URL func (directLinkProvider *DirectLinkProviderV2) SetServiceURL(url string) error { return directLinkProvider.Service.SetServiceURL(url) } +// GetServiceURL returns the service URL +func (directLinkProvider *DirectLinkProviderV2) GetServiceURL() string { + return directLinkProvider.Service.GetServiceURL() +} + +// SetDefaultHeaders sets HTTP headers to be sent in every request +func (directLinkProvider *DirectLinkProviderV2) SetDefaultHeaders(headers http.Header) { + directLinkProvider.Service.SetDefaultHeaders(headers) +} + +// SetEnableGzipCompression sets the service's EnableGzipCompression field +func (directLinkProvider *DirectLinkProviderV2) SetEnableGzipCompression(enableGzip bool) { + directLinkProvider.Service.SetEnableGzipCompression(enableGzip) +} + +// GetEnableGzipCompression returns the service's EnableGzipCompression field +func (directLinkProvider *DirectLinkProviderV2) GetEnableGzipCompression() bool { + return directLinkProvider.Service.GetEnableGzipCompression() +} + +// EnableRetries enables automatic retries for requests invoked for this service instance. +// If either parameter is specified as 0, then a default value is used instead. +func (directLinkProvider *DirectLinkProviderV2) EnableRetries(maxRetries int, maxRetryInterval time.Duration) { + directLinkProvider.Service.EnableRetries(maxRetries, maxRetryInterval) +} + +// DisableRetries disables automatic retries for requests invoked for this service instance. +func (directLinkProvider *DirectLinkProviderV2) DisableRetries() { + directLinkProvider.Service.DisableRetries() +} + // ListProviderGateways : List gateways // List all Direct Link Connect gateways created by this provider. func (directLinkProvider *DirectLinkProviderV2) ListProviderGateways(listProviderGatewaysOptions *ListProviderGatewaysOptions) (result *ProviderGatewayCollection, response *core.DetailedResponse, err error) { + return directLinkProvider.ListProviderGatewaysWithContext(context.Background(), listProviderGatewaysOptions) +} + +// ListProviderGatewaysWithContext is an alternate form of the ListProviderGateways method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) ListProviderGatewaysWithContext(ctx context.Context, listProviderGatewaysOptions *ListProviderGatewaysOptions) (result *ProviderGatewayCollection, response *core.DetailedResponse, err error) { err = core.ValidateStruct(listProviderGatewaysOptions, "listProviderGatewaysOptions") if err != nil { return } - pathSegments := []string{"gateways"} - pathParameters := []string{} - builder := core.NewRequestBuilder(core.GET) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/gateways`, nil) if err != nil { return } @@ -167,11 +224,13 @@ func (directLinkProvider *DirectLinkProviderV2) ListProviderGateways(listProvide if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGatewayCollection) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGatewayCollection) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -181,6 +240,11 @@ func (directLinkProvider *DirectLinkProviderV2) ListProviderGateways(listProvide // // The gateway will be 'provider_api_managed=true'. func (directLinkProvider *DirectLinkProviderV2) CreateProviderGateway(createProviderGatewayOptions *CreateProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { + return directLinkProvider.CreateProviderGatewayWithContext(context.Background(), createProviderGatewayOptions) +} + +// CreateProviderGatewayWithContext is an alternate form of the CreateProviderGateway method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) CreateProviderGatewayWithContext(ctx context.Context, createProviderGatewayOptions *CreateProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(createProviderGatewayOptions, "createProviderGatewayOptions cannot be nil") if err != nil { return @@ -190,11 +254,10 @@ func (directLinkProvider *DirectLinkProviderV2) CreateProviderGateway(createProv return } - pathSegments := []string{"gateways"} - pathParameters := []string{} - builder := core.NewRequestBuilder(core.POST) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/gateways`, nil) if err != nil { return } @@ -252,11 +315,13 @@ func (directLinkProvider *DirectLinkProviderV2) CreateProviderGateway(createProv if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -264,6 +329,11 @@ func (directLinkProvider *DirectLinkProviderV2) CreateProviderGateway(createProv // DeleteProviderGateway : Delete gateway // Delete a Direct Link Connect provider managed gateway. func (directLinkProvider *DirectLinkProviderV2) DeleteProviderGateway(deleteProviderGatewayOptions *DeleteProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { + return directLinkProvider.DeleteProviderGatewayWithContext(context.Background(), deleteProviderGatewayOptions) +} + +// DeleteProviderGatewayWithContext is an alternate form of the DeleteProviderGateway method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) DeleteProviderGatewayWithContext(ctx context.Context, deleteProviderGatewayOptions *DeleteProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(deleteProviderGatewayOptions, "deleteProviderGatewayOptions cannot be nil") if err != nil { return @@ -273,11 +343,14 @@ func (directLinkProvider *DirectLinkProviderV2) DeleteProviderGateway(deleteProv return } - pathSegments := []string{"gateways"} - pathParameters := []string{*deleteProviderGatewayOptions.ID} + pathParamsMap := map[string]string{ + "id": *deleteProviderGatewayOptions.ID, + } builder := core.NewRequestBuilder(core.DELETE) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/gateways/{id}`, pathParamsMap) if err != nil { return } @@ -304,11 +377,13 @@ func (directLinkProvider *DirectLinkProviderV2) DeleteProviderGateway(deleteProv if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -317,6 +392,11 @@ func (directLinkProvider *DirectLinkProviderV2) DeleteProviderGateway(deleteProv // Get a Direct Link Connect gateway. // Gateways with either `provider_api_managed=true` or `provider_api_managed=false` can be retrieved. func (directLinkProvider *DirectLinkProviderV2) GetProviderGateway(getProviderGatewayOptions *GetProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { + return directLinkProvider.GetProviderGatewayWithContext(context.Background(), getProviderGatewayOptions) +} + +// GetProviderGatewayWithContext is an alternate form of the GetProviderGateway method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) GetProviderGatewayWithContext(ctx context.Context, getProviderGatewayOptions *GetProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getProviderGatewayOptions, "getProviderGatewayOptions cannot be nil") if err != nil { return @@ -326,11 +406,14 @@ func (directLinkProvider *DirectLinkProviderV2) GetProviderGateway(getProviderGa return } - pathSegments := []string{"gateways"} - pathParameters := []string{*getProviderGatewayOptions.ID} + pathParamsMap := map[string]string{ + "id": *getProviderGatewayOptions.ID, + } builder := core.NewRequestBuilder(core.GET) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/gateways/{id}`, pathParamsMap) if err != nil { return } @@ -357,11 +440,13 @@ func (directLinkProvider *DirectLinkProviderV2) GetProviderGateway(getProviderGa if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -372,6 +457,11 @@ func (directLinkProvider *DirectLinkProviderV2) GetProviderGateway(getProviderGa // Name changes are applied immediately, other changes result in a gateway change_request and require approval from the // client. func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGateway(updateProviderGatewayOptions *UpdateProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { + return directLinkProvider.UpdateProviderGatewayWithContext(context.Background(), updateProviderGatewayOptions) +} + +// UpdateProviderGatewayWithContext is an alternate form of the UpdateProviderGateway method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGatewayWithContext(ctx context.Context, updateProviderGatewayOptions *UpdateProviderGatewayOptions) (result *ProviderGateway, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(updateProviderGatewayOptions, "updateProviderGatewayOptions cannot be nil") if err != nil { return @@ -381,11 +471,14 @@ func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGateway(updateProv return } - pathSegments := []string{"gateways"} - pathParameters := []string{*updateProviderGatewayOptions.ID} + pathParamsMap := map[string]string{ + "id": *updateProviderGatewayOptions.ID, + } builder := core.NewRequestBuilder(core.PATCH) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/gateways/{id}`, pathParamsMap) if err != nil { return } @@ -404,6 +497,15 @@ func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGateway(updateProv builder.AddQuery("version", fmt.Sprint(*directLinkProvider.Version)) body := make(map[string]interface{}) + if updateProviderGatewayOptions.BgpAsn != nil { + body["bgp_asn"] = updateProviderGatewayOptions.BgpAsn + } + if updateProviderGatewayOptions.BgpCerCidr != nil { + body["bgp_cer_cidr"] = updateProviderGatewayOptions.BgpCerCidr + } + if updateProviderGatewayOptions.BgpIbmCidr != nil { + body["bgp_ibm_cidr"] = updateProviderGatewayOptions.BgpIbmCidr + } if updateProviderGatewayOptions.Name != nil { body["name"] = updateProviderGatewayOptions.Name } @@ -425,11 +527,13 @@ func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGateway(updateProv if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderGateway) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -437,16 +541,20 @@ func (directLinkProvider *DirectLinkProviderV2) UpdateProviderGateway(updateProv // ListProviderPorts : List ports // List all provider ports (associated with the caller). func (directLinkProvider *DirectLinkProviderV2) ListProviderPorts(listProviderPortsOptions *ListProviderPortsOptions) (result *ProviderPortCollection, response *core.DetailedResponse, err error) { + return directLinkProvider.ListProviderPortsWithContext(context.Background(), listProviderPortsOptions) +} + +// ListProviderPortsWithContext is an alternate form of the ListProviderPorts method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) ListProviderPortsWithContext(ctx context.Context, listProviderPortsOptions *ListProviderPortsOptions) (result *ProviderPortCollection, response *core.DetailedResponse, err error) { err = core.ValidateStruct(listProviderPortsOptions, "listProviderPortsOptions") if err != nil { return } - pathSegments := []string{"ports"} - pathParameters := []string{} - builder := core.NewRequestBuilder(core.GET) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/ports`, nil) if err != nil { return } @@ -479,11 +587,13 @@ func (directLinkProvider *DirectLinkProviderV2) ListProviderPorts(listProviderPo if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderPortCollection) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderPortCollection) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -491,6 +601,11 @@ func (directLinkProvider *DirectLinkProviderV2) ListProviderPorts(listProviderPo // GetProviderPort : Get port // Get provider port information. func (directLinkProvider *DirectLinkProviderV2) GetProviderPort(getProviderPortOptions *GetProviderPortOptions) (result *ProviderPort, response *core.DetailedResponse, err error) { + return directLinkProvider.GetProviderPortWithContext(context.Background(), getProviderPortOptions) +} + +// GetProviderPortWithContext is an alternate form of the GetProviderPort method which supports a Context parameter +func (directLinkProvider *DirectLinkProviderV2) GetProviderPortWithContext(ctx context.Context, getProviderPortOptions *GetProviderPortOptions) (result *ProviderPort, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getProviderPortOptions, "getProviderPortOptions cannot be nil") if err != nil { return @@ -500,11 +615,14 @@ func (directLinkProvider *DirectLinkProviderV2) GetProviderPort(getProviderPortO return } - pathSegments := []string{"ports"} - pathParameters := []string{*getProviderPortOptions.ID} + pathParamsMap := map[string]string{ + "id": *getProviderPortOptions.ID, + } builder := core.NewRequestBuilder(core.GET) - _, err = builder.ConstructHTTPURL(directLinkProvider.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLinkProvider.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLinkProvider.Service.Options.URL, `/ports/{id}`, pathParamsMap) if err != nil { return } @@ -531,11 +649,13 @@ func (directLinkProvider *DirectLinkProviderV2) GetProviderPort(getProviderPortO if err != nil { return } - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderPort) - if err != nil { - return + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalProviderPort) + if err != nil { + return + } + response.Result = result } - response.Result = result return } @@ -546,20 +666,20 @@ type CreateProviderGatewayOptions struct { // // For a 2-byte range, enter a value between 1-64495 or 64999. For a 2-byte or 4-byte range, enter a value between // 131072-4199999999. For a 4-byte range, enter a value between 4201000000-4201064511. - BgpAsn *int64 `json:"bgp_asn" validate:"required"` + BgpAsn *int64 `validate:"required"` // Customer IBM Cloud account ID for the new gateway. A gateway object containing the pending create request will // become available in the specified account. - CustomerAccountID *string `json:"customer_account_id" validate:"required"` + CustomerAccountID *string `validate:"required"` // The unique user-defined name for this gateway. - Name *string `json:"name" validate:"required"` + Name *string `validate:"required"` // Select Port Label for the gateway. - Port *ProviderGatewayPortIdentity `json:"port" validate:"required"` + Port *ProviderGatewayPortIdentity `validate:"required"` // Gateway speed in megabits per second. - SpeedMbps *int64 `json:"speed_mbps" validate:"required"` + SpeedMbps *int64 `validate:"required"` // BGP customer edge router CIDR. // @@ -569,7 +689,7 @@ type CreateProviderGatewayOptions struct { // For manual IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and // bgp_ibm_cidr must have matching network and subnet mask values. - BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + BgpCerCidr *string // BGP IBM CIDR. // @@ -579,10 +699,10 @@ type CreateProviderGatewayOptions struct { // For manual IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and // bgp_ibm_cidr must have matching network and subnet mask values. - BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` + BgpIbmCidr *string // When true, perform request validation only and do not create a gateway. - CheckOnly *string `json:"check_only,omitempty"` + CheckOnly *string // Allows users to set headers on API requests Headers map[string]string @@ -656,7 +776,7 @@ func (options *CreateProviderGatewayOptions) SetHeaders(param map[string]string) // DeleteProviderGatewayOptions : The DeleteProviderGateway options. type DeleteProviderGatewayOptions struct { // Direct Link Connect gateway identifier. - ID *string `json:"id" validate:"required"` + ID *string `validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -684,7 +804,7 @@ func (options *DeleteProviderGatewayOptions) SetHeaders(param map[string]string) // GetProviderGatewayOptions : The GetProviderGateway options. type GetProviderGatewayOptions struct { // Direct Link Connect gateway identifier. - ID *string `json:"id" validate:"required"` + ID *string `validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -712,7 +832,7 @@ func (options *GetProviderGatewayOptions) SetHeaders(param map[string]string) *G // GetProviderPortOptions : The GetProviderPort options. type GetProviderPortOptions struct { // port identifier. - ID *string `json:"id" validate:"required"` + ID *string `validate:"required,ne="` // Allows users to set headers on API requests Headers map[string]string @@ -740,10 +860,10 @@ func (options *GetProviderPortOptions) SetHeaders(param map[string]string) *GetP // ListProviderGatewaysOptions : The ListProviderGateways options. type ListProviderGatewaysOptions struct { // A server-supplied token determining which resource to start the page on. - Start *string `json:"start,omitempty"` + Start *string // The number of resources to return on a page. - Limit *int64 `json:"limit,omitempty"` + Limit *int64 // Allows users to set headers on API requests Headers map[string]string @@ -775,10 +895,10 @@ func (options *ListProviderGatewaysOptions) SetHeaders(param map[string]string) // ListProviderPortsOptions : The ListProviderPorts options. type ListProviderPortsOptions struct { // A server-supplied token determining which resource to start the page on. - Start *string `json:"start,omitempty"` + Start *string // The number of resources to return on a page. - Limit *int64 `json:"limit,omitempty"` + Limit *int64 // Allows users to set headers on API requests Headers map[string]string @@ -826,7 +946,7 @@ type ProviderGateway struct { // Gateway BGP status. // - // The list of enumerated values for this property may expand in the future. Code and processes using this field must + // The list of enumerated values for this property may expand in the future. Code and processes using this field must // tolerate unexpected values. BgpStatus *string `json:"bgp_status,omitempty"` @@ -849,7 +969,7 @@ type ProviderGateway struct { // Gateway operational status. // - // The list of enumerated values for this property may expand in the future. Code and processes using this field must + // The list of enumerated values for this property may expand in the future. Code and processes using this field must // tolerate unexpected values. OperationalStatus *string `json:"operational_status" validate:"required"` @@ -874,7 +994,7 @@ type ProviderGateway struct { // Constants associated with the ProviderGateway.BgpStatus property. // Gateway BGP status. // -// The list of enumerated values for this property may expand in the future. Code and processes using this field must +// The list of enumerated values for this property may expand in the future. Code and processes using this field must // tolerate unexpected values. const ( ProviderGateway_BgpStatus_Active = "active" @@ -886,9 +1006,10 @@ const ( // Constants associated with the ProviderGateway.OperationalStatus property. // Gateway operational status. // -// The list of enumerated values for this property may expand in the future. Code and processes using this field must +// The list of enumerated values for this property may expand in the future. Code and processes using this field must // tolerate unexpected values. const ( + ProviderGateway_OperationalStatus_Configuring = "configuring" ProviderGateway_OperationalStatus_CreatePending = "create_pending" ProviderGateway_OperationalStatus_CreateRejected = "create_rejected" ProviderGateway_OperationalStatus_DeletePending = "delete_pending" @@ -1144,9 +1265,33 @@ func UnmarshalProviderGatewayPortReference(m map[string]json.RawMessage, result // ProviderGatewayUpdateAttributesUpdatesItem : ProviderGatewayUpdateAttributesUpdatesItem struct // Models which "extend" this model: // - ProviderGatewayUpdateAttributesUpdatesItemProviderGatewaySpeedUpdate +// - ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate +// - ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate type ProviderGatewayUpdateAttributesUpdatesItem struct { // New gateway speed in megabits per second. SpeedMbps *int64 `json:"speed_mbps,omitempty"` + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` + + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` } func (*ProviderGatewayUpdateAttributesUpdatesItem) isaProviderGatewayUpdateAttributesUpdatesItem() bool { @@ -1164,6 +1309,18 @@ func UnmarshalProviderGatewayUpdateAttributesUpdatesItem(m map[string]json.RawMe if err != nil { return } + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -1309,13 +1466,32 @@ func UnmarshalProviderPortCollectionNext(m map[string]json.RawMessage, result in // UpdateProviderGatewayOptions : The UpdateProviderGateway options. type UpdateProviderGatewayOptions struct { // Direct Link Connect gateway identifier. - ID *string `json:"id" validate:"required"` + ID *string `validate:"required,ne="` + + // The autonomous system number (ASN) of Border Gateway Protocol (BGP) configuration for the IBM side of the DL 2.0 + // gateway. + BgpAsn *int64 + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. Customer edge IP and IBM IP should be in the same network. Updating customer edge + // router CIDR should be accompanied with IBM CIDR in the request. Update customer edge router IP to a valid + // bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of "10.254.0.0/16", "172.16.0.0/12", + // "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching + // network and subnet mask values. + BgpCerCidr *string + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with + // customer edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value + // must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string // The unique user-defined name for this gateway. - Name *string `json:"name,omitempty"` + Name *string // Gateway speed in megabits per second. - SpeedMbps *int64 `json:"speed_mbps,omitempty"` + SpeedMbps *int64 // Allows users to set headers on API requests Headers map[string]string @@ -1334,6 +1510,24 @@ func (options *UpdateProviderGatewayOptions) SetID(id string) *UpdateProviderGat return options } +// SetBgpAsn : Allow user to set BgpAsn +func (options *UpdateProviderGatewayOptions) SetBgpAsn(bgpAsn int64) *UpdateProviderGatewayOptions { + options.BgpAsn = core.Int64Ptr(bgpAsn) + return options +} + +// SetBgpCerCidr : Allow user to set BgpCerCidr +func (options *UpdateProviderGatewayOptions) SetBgpCerCidr(bgpCerCidr string) *UpdateProviderGatewayOptions { + options.BgpCerCidr = core.StringPtr(bgpCerCidr) + return options +} + +// SetBgpIbmCidr : Allow user to set BgpIbmCidr +func (options *UpdateProviderGatewayOptions) SetBgpIbmCidr(bgpIbmCidr string) *UpdateProviderGatewayOptions { + options.BgpIbmCidr = core.StringPtr(bgpIbmCidr) + return options +} + // SetName : Allow user to set Name func (options *UpdateProviderGatewayOptions) SetName(name string) *UpdateProviderGatewayOptions { options.Name = core.StringPtr(name) @@ -1443,6 +1637,71 @@ func UnmarshalProviderGatewayChangeRequestProviderGatewayUpdateAttributes(m map[ return } +// ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate : The autonomous system number (ASN) of Border Gateway Protocol +// (BGP) configuration for the IBM side of the DL 2.0 gateway. +// This model "extends" ProviderGatewayUpdateAttributesUpdatesItem +type ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate struct { + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` +} + +func (*ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate) isaProviderGatewayUpdateAttributesUpdatesItem() bool { + return true +} + +// UnmarshalProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate unmarshals an instance of ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate from the specified map of raw messages. +func UnmarshalProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPASNUpdate) + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate : Update BGP customer and IBM CIDR. +// This model "extends" ProviderGatewayUpdateAttributesUpdatesItem +type ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate struct { + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` +} + +func (*ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate) isaProviderGatewayUpdateAttributesUpdatesItem() bool { + return true +} + +// UnmarshalProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate unmarshals an instance of ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate from the specified map of raw messages. +func UnmarshalProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ProviderGatewayUpdateAttributesUpdatesItemProviderGatewayBGPIPUpdate) + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // ProviderGatewayUpdateAttributesUpdatesItemProviderGatewaySpeedUpdate : gateway speed change. // This model "extends" ProviderGatewayUpdateAttributesUpdatesItem type ProviderGatewayUpdateAttributesUpdatesItemProviderGatewaySpeedUpdate struct { diff --git a/directlinkproviderv2/direct_link_provider_v2_integration_test.go b/directlinkproviderv2/direct_link_provider_v2_integration_test.go index 791dd65..1f07d79 100644 --- a/directlinkproviderv2/direct_link_provider_v2_integration_test.go +++ b/directlinkproviderv2/direct_link_provider_v2_integration_test.go @@ -514,7 +514,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { shouldSkipTest() createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), - "update_attributes_approve") + directlinkv1.CreateGatewayActionOptions_Action_UpdateAttributesApprove) gatewayActionTemplateUpdatesItem := new(directlinkv1.GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate) gatewayActionTemplateUpdatesItem.SpeedMbps = core.Int64Ptr(updatedSpeedMbps) @@ -586,9 +586,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { gatewayId := os.Getenv("GATEWAY_ID") deteleGatewayOptions := serviceV2.NewDeleteProviderGatewayOptions(gatewayId) - _, detailedResponse, _ := serviceV2.DeleteProviderGateway(deteleGatewayOptions) - Expect(detailedResponse.StatusCode).To(Equal(202)) }) @@ -596,11 +594,9 @@ var _ = Describe(`DirectLinkProviderV2`, func() { shouldSkipTest() createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), - "delete_gateway_reject") - + directlinkv1.CreateGatewayActionOptions_Action_DeleteGatewayReject) // Get the current status for the gateway _, detailedResponse, _ := serviceV1.CreateGatewayAction(createGatewayActionOptions) - Expect(detailedResponse.StatusCode).To(Equal(200)) }) @@ -608,13 +604,10 @@ var _ = Describe(`DirectLinkProviderV2`, func() { shouldSkipTest() getGatewayOptions := serviceV1.NewGetGatewayOptions(os.Getenv("GATEWAY_ID")) - // Get the current status for the gateway result, detailedResponse, err := serviceV1.GetGateway(getGatewayOptions) - Expect(err).To(BeNil()) Expect(detailedResponse.StatusCode).To(Equal(200)) - // change request has been reset Expect(result.ChangeRequest).To(BeNil()) }) @@ -659,9 +652,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { gatewayId := os.Getenv("GATEWAY_ID") deteleGatewayOptions := serviceV2.NewDeleteProviderGatewayOptions(gatewayId) - _, detailedResponse, _ := serviceV2.DeleteProviderGateway(deteleGatewayOptions) - Expect(detailedResponse.StatusCode).To(Equal(202)) }) @@ -669,11 +660,9 @@ var _ = Describe(`DirectLinkProviderV2`, func() { shouldSkipTest() createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), - "delete_gateway_approve") - + directlinkv1.CreateGatewayActionOptions_Action_DeleteGatewayApprove) // Get the current status for the gateway _, detailedResponse, _ := serviceV1.CreateGatewayAction(createGatewayActionOptions) - Expect(detailedResponse.StatusCode).To(Equal(204)) }) }) @@ -812,9 +801,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { gatewayId := os.Getenv("GATEWAY_ID") deteleGatewayOptions := serviceV2.NewDeleteProviderGatewayOptions(gatewayId) - _, detailedResponse, _ := serviceV2.DeleteProviderGateway(deteleGatewayOptions) - Expect(detailedResponse.StatusCode).To(Equal(202)) }) @@ -822,11 +809,353 @@ var _ = Describe(`DirectLinkProviderV2`, func() { shouldSkipTest() createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), - "delete_gateway_approve") + directlinkv1.CreateGatewayActionOptions_Action_DeleteGatewayApprove) + // Get the current status for the gateway + _, detailedResponse, _ := serviceV1.CreateGatewayAction(createGatewayActionOptions) + Expect(detailedResponse.StatusCode).To(Equal(204)) + }) + }) + + Describe("Direct Link Provider Gateways with BGP IP", func() { + timestamp := time.Now().Unix() + gatewayName := "GO-INT-SDK-PROVIDER-BGPIP-UPD-" + strconv.FormatInt(timestamp, 10) + bgpAsn := int64(64999) + customerAccount := os.Getenv("CUSTOMER_ACCT_ID") + speedMbps := int64(1000) + + // Construct an instance of the ProviderGatewayPortIdentity model + providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) + var firstPort directlinkproviderv2.ProviderPort + + It(`Successfully get a provider port`, func() { + shouldSkipTest() + + listPortsOptions := serviceV2.NewListProviderPortsOptions() + result, detailedResponse, err := serviceV2.ListProviderPorts(listPortsOptions) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + ports := result.Ports + firstPort = ports[0] + providerGatewayPortIdentityModel.ID = firstPort.ID + }) + + It(`Successfully create gateway`, func() { + shouldSkipTest() + + gatewayOptions := new(directlinkproviderv2.CreateProviderGatewayOptions) + gatewayOptions.BgpAsn = core.Int64Ptr(bgpAsn) + gatewayOptions.CustomerAccountID = core.StringPtr(customerAccount) + gatewayOptions.Name = core.StringPtr(gatewayName) + gatewayOptions.Port = providerGatewayPortIdentityModel + gatewayOptions.SpeedMbps = core.Int64Ptr(speedMbps) + + result, detailedResponse, err := serviceV2.CreateProviderGateway(gatewayOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(201)) + + os.Setenv("GATEWAY_ID", *result.ID) + }) + + It(`Successfully approve the provider created gateway`, func() { + shouldSkipTest() + + createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), + "create_gateway_approve") + createGatewayActionOptions.SetMetered(false) + createGatewayActionOptions.SetGlobal(false) + + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.CreateGatewayAction(createGatewayActionOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.BgpAsn).To(Equal(bgpAsn)) + Expect(*result.SpeedMbps).To(Equal(speedMbps)) + Expect(*result.BgpCerCidr).NotTo(BeEmpty()) + Expect(*result.BgpIbmCidr).NotTo(Equal("")) + Expect(*result.Global).To(Equal(false)) + Expect(*result.Metered).To(Equal(false)) + Expect(*result.OperationalStatus).To(Equal("create_pending")) + Expect(*result.Port.ID).To(Equal(*firstPort.ID)) + Expect(*result.ProviderApiManaged).To(Equal(true)) + Expect(*result.Type).To(Equal("connect")) + }) + + It("Successfully waits for connect gateway to move to provisioned state", func() { + shouldSkipTest() + + getGatewayOptions := serviceV1.NewGetGatewayOptions(os.Getenv("GATEWAY_ID")) + + // before a connect gateway can be deleted, it needs to have operational_status of provisioned. We need to wait for + // the new gateway to go to provisioned so we can delete it. + timer := 0 + for { + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.GetGateway(getGatewayOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + // if operational status is "provisioned" then we are done + if *result.OperationalStatus == "provisioned" { + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.OperationalStatus).To(Equal("provisioned")) + break + } + + // not provisioned yet, see if we have reached the timeout value. If so, exit with failure + if timer > 24 { // 2 min timer (24x5sec) + Expect(*result.OperationalStatus).To(Equal("provisioned")) // timed out fail if status is not provisioned + break + } else { + // Still exists, wait 5 sec + time.Sleep(time.Duration(5) * time.Second) + timer = timer + 1 + } + } + }) + + It("should successfully send the update request for bgp ASN AND BGP IP", func() { + shouldSkipTest() + + bgpAsn := int64(63999) + localIP := "172.17.252.1/29" + remoteIP := "172.17.252.2/29" + updateGatewayOptions := serviceV2.NewUpdateProviderGatewayOptions(os.Getenv("GATEWAY_ID")) + updateGatewayOptions.SetBgpAsn(bgpAsn).SetBgpCerCidr(remoteIP).SetBgpIbmCidr(localIP) + + // Get the current status for the gateway + result, detailedResponse, err := serviceV2.UpdateProviderGateway(updateGatewayOptions) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.BgpAsn).NotTo(Equal(bgpAsn)) + Expect(*result.BgpCerCidr).NotTo(Equal(remoteIP)) + Expect(*result.BgpIbmCidr).NotTo(Equal(localIP)) + }) + + It(`Successfully approve the update request`, func() { + shouldSkipTest() + + bgpAsn := int64(63999) + localIP := "172.17.252.1/29" + remoteIP := "172.17.252.2/29" + + // Create []updates array + bgpAsnUpdate := new(directlinkv1.GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate) + bgpAsnUpdate.BgpAsn = &bgpAsn + bgpIPUpdate := new(directlinkv1.GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate) + bgpIPUpdate.BgpCerCidr = &remoteIP + bgpIPUpdate.BgpIbmCidr = &localIP + var updateAttributes []directlinkv1.GatewayActionTemplateUpdatesItemIntf + updateAttributes = append(updateAttributes, bgpAsnUpdate, bgpIPUpdate) + + updateGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), + directlinkv1.CreateGatewayActionOptions_Action_UpdateAttributesApprove) + updateGatewayActionOptions.SetUpdates(updateAttributes) + + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.CreateGatewayAction(updateGatewayActionOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.OperationalStatus).To(Equal("configuring")) + Expect(*result.BgpAsn).To(Equal(bgpAsn)) + Expect(*result.BgpCerCidr).To(Equal(remoteIP)) + Expect(*result.BgpIbmCidr).To(Equal(localIP)) + }) + + It("Successfully waits for connect gateway to move to provisioned state", func() { + shouldSkipTest() + + getGatewayOptions := serviceV1.NewGetGatewayOptions(os.Getenv("GATEWAY_ID")) + + // before a connect gateway can be deleted, it needs to have operational_status of provisioned. We need to wait for + // the new gateway to go to provisioned so we can delete it. + timer := 0 + for { + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.GetGateway(getGatewayOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + // if operational status is "provisioned" then we are done + if *result.OperationalStatus == "provisioned" { + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.OperationalStatus).To(Equal("provisioned")) + break + } + // not provisioned yet, see if we have reached the timeout value. If so, exit with failure + if timer > 24 { // 2 min timer (24x5sec) + Expect(*result.OperationalStatus).To(Equal("provisioned")) // timed out fail if status is not provisioned + break + } else { + // Still exists, wait 5 sec + time.Sleep(time.Duration(5) * time.Second) + timer = timer + 1 + } + } + }) + + It("Successfully request gateway delete using provider account", func() { + shouldSkipTest() + + gatewayId := os.Getenv("GATEWAY_ID") + deteleGatewayOptions := serviceV2.NewDeleteProviderGatewayOptions(gatewayId) + _, detailedResponse, _ := serviceV2.DeleteProviderGateway(deteleGatewayOptions) + Expect(detailedResponse.StatusCode).To(Equal(202)) + }) + + It(`Successfully approve gateway delete using client account`, func() { + shouldSkipTest() + + createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), + directlinkv1.CreateGatewayActionOptions_Action_DeleteGatewayApprove) // Get the current status for the gateway _, detailedResponse, _ := serviceV1.CreateGatewayAction(createGatewayActionOptions) + Expect(detailedResponse.StatusCode).To(Equal(204)) + }) + }) + + Describe("Direct Link Provider Gateways with BFD Config IP", func() { + timestamp := time.Now().Unix() + gatewayName := "GO-INT-SDK-PROVIDER-BFD-" + strconv.FormatInt(timestamp, 10) + bgpAsn := int64(64999) + customerAccount := os.Getenv("CUSTOMER_ACCT_ID") + speedMbps := int64(1000) + + // Construct an instance of the ProviderGatewayPortIdentity model + providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) + var firstPort directlinkproviderv2.ProviderPort + + It(`Successfully get a provider port`, func() { + shouldSkipTest() + + listPortsOptions := serviceV2.NewListProviderPortsOptions() + result, detailedResponse, err := serviceV2.ListProviderPorts(listPortsOptions) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + ports := result.Ports + firstPort = ports[0] + providerGatewayPortIdentityModel.ID = firstPort.ID + }) + + It(`Successfully create gateway`, func() { + shouldSkipTest() + + gatewayOptions := new(directlinkproviderv2.CreateProviderGatewayOptions) + gatewayOptions.BgpAsn = core.Int64Ptr(bgpAsn) + gatewayOptions.CustomerAccountID = core.StringPtr(customerAccount) + gatewayOptions.Name = core.StringPtr(gatewayName) + gatewayOptions.Port = providerGatewayPortIdentityModel + gatewayOptions.SpeedMbps = core.Int64Ptr(speedMbps) + + result, detailedResponse, err := serviceV2.CreateProviderGateway(gatewayOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(201)) + os.Setenv("GATEWAY_ID", *result.ID) + }) + + It(`Successfully approve the provider created gateway`, func() { + shouldSkipTest() + + bfdInterval := int64(1000) + bfdMultiplier := int64(10) + bfdConfigTemplate := new(directlinkv1.GatewayBfdConfigActionTemplate) + bfdConfigTemplate.Interval = &bfdInterval + bfdConfigTemplate.Multiplier = &bfdMultiplier + + createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), + "create_gateway_approve") + createGatewayActionOptions.SetMetered(false) + createGatewayActionOptions.SetGlobal(false) + createGatewayActionOptions.SetBfdConfig(bfdConfigTemplate) + + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.CreateGatewayAction(createGatewayActionOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.BgpAsn).To(Equal(bgpAsn)) + Expect(*result.SpeedMbps).To(Equal(speedMbps)) + Expect(*result.Global).To(Equal(false)) + Expect(*result.Metered).To(Equal(false)) + Expect(*result.OperationalStatus).To(Equal("create_pending")) + Expect(*result.Port.ID).To(Equal(*firstPort.ID)) + Expect(*result.ProviderApiManaged).To(Equal(true)) + Expect(*result.Type).To(Equal("connect")) + Expect(result.BfdConfig).NotTo(BeNil()) + Expect(*result.BfdConfig.Interval).To(Equal(bfdInterval)) + Expect(*result.BfdConfig.Multiplier).To(Equal(bfdMultiplier)) + }) + + It("Successfully waits for connect gateway to move to provisioned state", func() { + shouldSkipTest() + + getGatewayOptions := serviceV1.NewGetGatewayOptions(os.Getenv("GATEWAY_ID")) + + // before a connect gateway can be deleted, it needs to have operational_status of provisioned. We need to wait for + // the new gateway to go to provisioned so we can delete it. + timer := 0 + for { + // Get the current status for the gateway + result, detailedResponse, err := serviceV1.GetGateway(getGatewayOptions) + + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + + // if operational status is "provisioned" then we are done + if *result.OperationalStatus == "provisioned" { + Expect(*result.ID).To(Equal(os.Getenv("GATEWAY_ID"))) + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.OperationalStatus).To(Equal("provisioned")) + break + } + + // not provisioned yet, see if we have reached the timeout value. If so, exit with failure + if timer > 24 { // 2 min timer (24x5sec) + Expect(*result.OperationalStatus).To(Equal("provisioned")) // timed out fail if status is not provisioned + break + } else { + // Still exists, wait 5 sec + time.Sleep(time.Duration(5) * time.Second) + timer = timer + 1 + } + } + }) + + It("Successfully request gateway delete using provider account", func() { + shouldSkipTest() + + deteleGatewayOptions := serviceV2.NewDeleteProviderGatewayOptions(os.Getenv("GATEWAY_ID")) + _, detailedResponse, _ := serviceV2.DeleteProviderGateway(deteleGatewayOptions) + Expect(detailedResponse.StatusCode).To(Equal(202)) + }) + + It(`Successfully approve gateway delete using client account`, func() { + shouldSkipTest() + + createGatewayActionOptions := serviceV1.NewCreateGatewayActionOptions(os.Getenv("GATEWAY_ID"), + directlinkv1.CreateGatewayActionOptions_Action_DeleteGatewayApprove) + // Get the current status for the gateway + _, detailedResponse, _ := serviceV1.CreateGatewayAction(createGatewayActionOptions) Expect(detailedResponse.StatusCode).To(Equal(204)) }) }) diff --git a/directlinkproviderv2/direct_link_provider_v2_suite_test.go b/directlinkproviderv2/direct_link_provider_v2_suite_test.go index 7c97889..1dc512f 100644 --- a/directlinkproviderv2/direct_link_provider_v2_suite_test.go +++ b/directlinkproviderv2/direct_link_provider_v2_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/directlinkproviderv2/direct_link_provider_v2_test.go b/directlinkproviderv2/direct_link_provider_v2_test.go index 2a07afa..8efbc34 100644 --- a/directlinkproviderv2/direct_link_provider_v2_test.go +++ b/directlinkproviderv2/direct_link_provider_v2_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package directlinkproviderv2_test import ( "bytes" + "context" "fmt" "io" "io/ioutil" @@ -26,7 +27,7 @@ import ( "os" "time" - "github.com/IBM/go-sdk-core/v4/core" + "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/networking-go-sdk/directlinkproviderv2" "github.com/go-openapi/strfmt" . "github.com/onsi/ginkgo" @@ -38,23 +39,23 @@ var _ = Describe(`DirectLinkProviderV2`, func() { Describe(`Service constructor tests`, func() { version := "testString" It(`Instantiate service client`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testService).ToNot(BeNil()) - Expect(testServiceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) }) It(`Instantiate service client with error: Invalid URL`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: "{BAD_URL_STRING", Version: core.StringPtr(version), }) - Expect(testService).To(BeNil()) - Expect(testServiceErr).ToNot(BeNil()) + Expect(directLinkProviderService).To(BeNil()) + Expect(serviceErr).ToNot(BeNil()) }) It(`Instantiate service client with error: Invalid Auth`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: "https://directlinkproviderv2/api", Version: core.StringPtr(version), Authenticator: &core.BasicAuthenticator{ @@ -62,13 +63,13 @@ var _ = Describe(`DirectLinkProviderV2`, func() { Password: "", }, }) - Expect(testService).To(BeNil()) - Expect(testServiceErr).ToNot(BeNil()) + Expect(directLinkProviderService).To(BeNil()) + Expect(serviceErr).ToNot(BeNil()) }) It(`Instantiate service client with error: Validation Error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{}) - Expect(testService).To(BeNil()) - Expect(testServiceErr).ToNot(BeNil()) + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{}) + Expect(directLinkProviderService).To(BeNil()) + Expect(serviceErr).ToNot(BeNil()) }) }) Describe(`Service constructor tests using external config`, func() { @@ -82,35 +83,53 @@ var _ = Describe(`DirectLinkProviderV2`, func() { It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ Version: core.StringPtr(version), }) - Expect(testService).ToNot(BeNil()) - Expect(testServiceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) + + clone := directLinkProviderService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != directLinkProviderService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(directLinkProviderService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(directLinkProviderService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url from constructor successfully`, func() { SetTestEnvironment(testEnvironment) - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: "https://testService/api", Version: core.StringPtr(version), }) - Expect(testService).ToNot(BeNil()) - Expect(testServiceErr).To(BeNil()) - Expect(testService.Service.GetServiceURL()).To(Equal("https://testService/api")) + Expect(directLinkProviderService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := directLinkProviderService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != directLinkProviderService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(directLinkProviderService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(directLinkProviderService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ Version: core.StringPtr(version), }) - err := testService.SetServiceURL("https://testService/api") + err := directLinkProviderService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) - Expect(testService).ToNot(BeNil()) - Expect(testServiceErr).To(BeNil()) - Expect(testService.Service.GetServiceURL()).To(Equal("https://testService/api")) + Expect(directLinkProviderService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := directLinkProviderService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != directLinkProviderService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(directLinkProviderService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(directLinkProviderService.Service.Options.Authenticator)) }) }) Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { @@ -121,13 +140,13 @@ var _ = Describe(`DirectLinkProviderV2`, func() { } SetTestEnvironment(testEnvironment) - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ Version: core.StringPtr(version), }) It(`Instantiate service client with error`, func() { - Expect(testService).To(BeNil()) - Expect(testServiceErr).ToNot(BeNil()) + Expect(directLinkProviderService).To(BeNil()) + Expect(serviceErr).ToNot(BeNil()) ClearTestEnvironment(testEnvironment) }) }) @@ -138,56 +157,70 @@ var _ = Describe(`DirectLinkProviderV2`, func() { } SetTestEnvironment(testEnvironment) - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2UsingExternalConfig(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: "{BAD_URL_STRING", Version: core.StringPtr(version), }) It(`Instantiate service client with error`, func() { - Expect(testService).To(BeNil()) - Expect(testServiceErr).ToNot(BeNil()) + Expect(directLinkProviderService).To(BeNil()) + Expect(serviceErr).ToNot(BeNil()) ClearTestEnvironment(testEnvironment) }) }) }) + Describe(`Regional endpoint tests`, func() { + It(`GetServiceURLForRegion(region string)`, func() { + var url string + var err error + url, err = directlinkproviderv2.GetServiceURLForRegion("INVALID_REGION") + Expect(url).To(BeEmpty()) + Expect(err).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) + }) + }) Describe(`ListProviderGateways(listProviderGatewaysOptions *ListProviderGatewaysOptions) - Operation response error`, func() { version := "testString" listProviderGatewaysPath := "/gateways" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(listProviderGatewaysPath)) + Expect(req.URL.EscapedPath()).To(Equal(listProviderGatewaysPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(38))})) - + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke ListProviderGateways with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ListProviderGatewaysOptions model listProviderGatewaysOptionsModel := new(directlinkproviderv2.ListProviderGatewaysOptions) listProviderGatewaysOptionsModel.Start = core.StringPtr("testString") - listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderGatewaysOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.ListProviderGateways(listProviderGatewaysOptionsModel) + result, response, operationErr := directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -197,40 +230,100 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`ListProviderGateways(listProviderGatewaysOptions *ListProviderGatewaysOptions)`, func() { version := "testString" listProviderGatewaysPath := "/gateways" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(listProviderGatewaysPath)) + Expect(req.URL.EscapedPath()).To(Equal(listProviderGatewaysPath)) Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(38))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}`) + })) + }) + It(`Invoke ListProviderGateways successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the ListProviderGatewaysOptions model + listProviderGatewaysOptionsModel := new(directlinkproviderv2.ListProviderGatewaysOptions) + listProviderGatewaysOptionsModel.Start = core.StringPtr("testString") + listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(1)) + listProviderGatewaysOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.ListProviderGatewaysWithContext(ctx, listProviderGatewaysOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.ListProviderGatewaysWithContext(ctx, listProviderGatewaysOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listProviderGatewaysPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/gateways?start=8c4a91a3e2cbd233b5a5b33436855fc2&limit=100", "start": "8c4a91a3e2cbd233b5a5b33436855fc2"}, "total_count": 132, "gateways": [{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}]}`) })) }) It(`Invoke ListProviderGateways successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.ListProviderGateways(nil) + result, response, operationErr := directLinkProviderService.ListProviderGateways(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -238,33 +331,34 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the ListProviderGatewaysOptions model listProviderGatewaysOptionsModel := new(directlinkproviderv2.ListProviderGatewaysOptions) listProviderGatewaysOptionsModel.Start = core.StringPtr("testString") - listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderGatewaysOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.ListProviderGateways(listProviderGatewaysOptionsModel) + result, response, operationErr = directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke ListProviderGateways with error: Operation request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ListProviderGatewaysOptions model listProviderGatewaysOptionsModel := new(directlinkproviderv2.ListProviderGatewaysOptions) listProviderGatewaysOptionsModel.Start = core.StringPtr("testString") - listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderGatewaysOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.ListProviderGateways(listProviderGatewaysOptionsModel) + result, response, operationErr := directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -274,35 +368,69 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListProviderGateways successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the ListProviderGatewaysOptions model + listProviderGatewaysOptionsModel := new(directlinkproviderv2.ListProviderGatewaysOptions) + listProviderGatewaysOptionsModel.Start = core.StringPtr("testString") + listProviderGatewaysOptionsModel.Limit = core.Int64Ptr(int64(1)) + listProviderGatewaysOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.ListProviderGateways(listProviderGatewaysOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`CreateProviderGateway(createProviderGatewayOptions *CreateProviderGatewayOptions) - Operation response error`, func() { version := "testString" createProviderGatewayPath := "/gateways" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(createProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(createProviderGatewayPath)) Expect(req.Method).To(Equal("POST")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["check_only"]).To(Equal([]string{"testString"})) - res.Header().Set("Content-type", "application/json") res.WriteHeader(201) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke CreateProviderGateway with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ProviderGatewayPortIdentity model providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) @@ -311,7 +439,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the CreateProviderGatewayOptions model createProviderGatewayOptionsModel := new(directlinkproviderv2.CreateProviderGatewayOptions) createProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) - createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("57a7d05f36894e3cb9b46a43556d903e") + createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("4111d05f36894e3cb9b46a43556d9000") createProviderGatewayOptionsModel.Name = core.StringPtr("myGateway") createProviderGatewayOptionsModel.Port = providerGatewayPortIdentityModel createProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) @@ -320,7 +448,14 @@ var _ = Describe(`DirectLinkProviderV2`, func() { createProviderGatewayOptionsModel.CheckOnly = core.StringPtr("testString") createProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.CreateProviderGateway(createProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -330,38 +465,140 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`CreateProviderGateway(createProviderGatewayOptions *CreateProviderGatewayOptions)`, func() { version := "testString" createProviderGatewayPath := "/gateways" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(createProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(createProviderGatewayPath)) Expect(req.Method).To(Equal("POST")) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["check_only"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + })) + }) + It(`Invoke CreateProviderGateway successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the ProviderGatewayPortIdentity model + providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) + providerGatewayPortIdentityModel.ID = core.StringPtr("fffdcb1a-fee4-41c7-9e11-9cd99e65c777") + + // Construct an instance of the CreateProviderGatewayOptions model + createProviderGatewayOptionsModel := new(directlinkproviderv2.CreateProviderGatewayOptions) + createProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("4111d05f36894e3cb9b46a43556d9000") + createProviderGatewayOptionsModel.Name = core.StringPtr("myGateway") + createProviderGatewayOptionsModel.Port = providerGatewayPortIdentityModel + createProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) + createProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("10.254.30.78/30") + createProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("10.254.30.77/30") + createProviderGatewayOptionsModel.CheckOnly = core.StringPtr("testString") + createProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.CreateProviderGatewayWithContext(ctx, createProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.CreateProviderGatewayWithContext(ctx, createProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createProviderGatewayPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["check_only"]).To(Equal([]string{"testString"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) })) }) It(`Invoke CreateProviderGateway successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.CreateProviderGateway(nil) + result, response, operationErr := directLinkProviderService.CreateProviderGateway(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -373,7 +610,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the CreateProviderGatewayOptions model createProviderGatewayOptionsModel := new(directlinkproviderv2.CreateProviderGatewayOptions) createProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) - createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("57a7d05f36894e3cb9b46a43556d903e") + createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("4111d05f36894e3cb9b46a43556d9000") createProviderGatewayOptionsModel.Name = core.StringPtr("myGateway") createProviderGatewayOptionsModel.Port = providerGatewayPortIdentityModel createProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) @@ -383,19 +620,20 @@ var _ = Describe(`DirectLinkProviderV2`, func() { createProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.CreateProviderGateway(createProviderGatewayOptionsModel) + result, response, operationErr = directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke CreateProviderGateway with error: Operation validation and request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ProviderGatewayPortIdentity model providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) @@ -404,7 +642,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the CreateProviderGatewayOptions model createProviderGatewayOptionsModel := new(directlinkproviderv2.CreateProviderGatewayOptions) createProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) - createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("57a7d05f36894e3cb9b46a43556d903e") + createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("4111d05f36894e3cb9b46a43556d9000") createProviderGatewayOptionsModel.Name = core.StringPtr("myGateway") createProviderGatewayOptionsModel.Port = providerGatewayPortIdentityModel createProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) @@ -413,9 +651,9 @@ var _ = Describe(`DirectLinkProviderV2`, func() { createProviderGatewayOptionsModel.CheckOnly = core.StringPtr("testString") createProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.CreateProviderGateway(createProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -423,7 +661,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct a second instance of the CreateProviderGatewayOptions model with no property values createProviderGatewayOptionsModelNew := new(directlinkproviderv2.CreateProviderGatewayOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = testService.CreateProviderGateway(createProviderGatewayOptionsModelNew) + result, response, operationErr = directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -432,40 +670,92 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateProviderGateway successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the ProviderGatewayPortIdentity model + providerGatewayPortIdentityModel := new(directlinkproviderv2.ProviderGatewayPortIdentity) + providerGatewayPortIdentityModel.ID = core.StringPtr("fffdcb1a-fee4-41c7-9e11-9cd99e65c777") + + // Construct an instance of the CreateProviderGatewayOptions model + createProviderGatewayOptionsModel := new(directlinkproviderv2.CreateProviderGatewayOptions) + createProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + createProviderGatewayOptionsModel.CustomerAccountID = core.StringPtr("4111d05f36894e3cb9b46a43556d9000") + createProviderGatewayOptionsModel.Name = core.StringPtr("myGateway") + createProviderGatewayOptionsModel.Port = providerGatewayPortIdentityModel + createProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) + createProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("10.254.30.78/30") + createProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("10.254.30.77/30") + createProviderGatewayOptionsModel.CheckOnly = core.StringPtr("testString") + createProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.CreateProviderGateway(createProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`DeleteProviderGateway(deleteProviderGatewayOptions *DeleteProviderGatewayOptions) - Operation response error`, func() { version := "testString" deleteProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(deleteProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteProviderGatewayPath)) Expect(req.Method).To(Equal("DELETE")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - res.Header().Set("Content-type", "application/json") res.WriteHeader(202) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke DeleteProviderGateway with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the DeleteProviderGatewayOptions model deleteProviderGatewayOptionsModel := new(directlinkproviderv2.DeleteProviderGatewayOptions) deleteProviderGatewayOptionsModel.ID = core.StringPtr("testString") deleteProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -475,36 +765,95 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`DeleteProviderGateway(deleteProviderGatewayOptions *DeleteProviderGatewayOptions)`, func() { version := "testString" deleteProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(deleteProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteProviderGatewayPath)) Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + })) + }) + It(`Invoke DeleteProviderGateway successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the DeleteProviderGatewayOptions model + deleteProviderGatewayOptionsModel := new(directlinkproviderv2.DeleteProviderGatewayOptions) + deleteProviderGatewayOptionsModel.ID = core.StringPtr("testString") + deleteProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.DeleteProviderGatewayWithContext(ctx, deleteProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.DeleteProviderGatewayWithContext(ctx, deleteProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteProviderGatewayPath)) + Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(202) - fmt.Fprintf(res, `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) })) }) It(`Invoke DeleteProviderGateway successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.DeleteProviderGateway(nil) + result, response, operationErr := directLinkProviderService.DeleteProviderGateway(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -515,28 +864,29 @@ var _ = Describe(`DirectLinkProviderV2`, func() { deleteProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + result, response, operationErr = directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke DeleteProviderGateway with error: Operation validation and request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the DeleteProviderGatewayOptions model deleteProviderGatewayOptionsModel := new(directlinkproviderv2.DeleteProviderGatewayOptions) deleteProviderGatewayOptionsModel.ID = core.StringPtr("testString") deleteProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -544,7 +894,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct a second instance of the DeleteProviderGatewayOptions model with no property values deleteProviderGatewayOptionsModelNew := new(directlinkproviderv2.DeleteProviderGatewayOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = testService.DeleteProviderGateway(deleteProviderGatewayOptionsModelNew) + result, response, operationErr = directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -553,40 +903,81 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteProviderGateway successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the DeleteProviderGatewayOptions model + deleteProviderGatewayOptionsModel := new(directlinkproviderv2.DeleteProviderGatewayOptions) + deleteProviderGatewayOptionsModel.ID = core.StringPtr("testString") + deleteProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.DeleteProviderGateway(deleteProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`GetProviderGateway(getProviderGatewayOptions *GetProviderGatewayOptions) - Operation response error`, func() { version := "testString" getProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(getProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(getProviderGatewayPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke GetProviderGateway with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the GetProviderGatewayOptions model getProviderGatewayOptionsModel := new(directlinkproviderv2.GetProviderGatewayOptions) getProviderGatewayOptionsModel.ID = core.StringPtr("testString") getProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.GetProviderGateway(getProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -596,36 +987,95 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`GetProviderGateway(getProviderGatewayOptions *GetProviderGatewayOptions)`, func() { version := "testString" getProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(getProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(getProviderGatewayPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + })) + }) + It(`Invoke GetProviderGateway successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the GetProviderGatewayOptions model + getProviderGatewayOptionsModel := new(directlinkproviderv2.GetProviderGatewayOptions) + getProviderGatewayOptionsModel.ID = core.StringPtr("testString") + getProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.GetProviderGatewayWithContext(ctx, getProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.GetProviderGatewayWithContext(ctx, getProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getProviderGatewayPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) })) }) It(`Invoke GetProviderGateway successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.GetProviderGateway(nil) + result, response, operationErr := directLinkProviderService.GetProviderGateway(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -636,28 +1086,29 @@ var _ = Describe(`DirectLinkProviderV2`, func() { getProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.GetProviderGateway(getProviderGatewayOptionsModel) + result, response, operationErr = directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke GetProviderGateway with error: Operation validation and request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the GetProviderGatewayOptions model getProviderGatewayOptionsModel := new(directlinkproviderv2.GetProviderGatewayOptions) getProviderGatewayOptionsModel.ID = core.StringPtr("testString") getProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.GetProviderGateway(getProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -665,7 +1116,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct a second instance of the GetProviderGatewayOptions model with no property values getProviderGatewayOptionsModelNew := new(directlinkproviderv2.GetProviderGatewayOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = testService.GetProviderGateway(getProviderGatewayOptionsModelNew) + result, response, operationErr = directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -674,42 +1125,86 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetProviderGateway successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the GetProviderGatewayOptions model + getProviderGatewayOptionsModel := new(directlinkproviderv2.GetProviderGatewayOptions) + getProviderGatewayOptionsModel.ID = core.StringPtr("testString") + getProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.GetProviderGateway(getProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`UpdateProviderGateway(updateProviderGatewayOptions *UpdateProviderGatewayOptions) - Operation response error`, func() { version := "testString" updateProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(updateProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateProviderGatewayPath)) Expect(req.Method).To(Equal("PATCH")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke UpdateProviderGateway with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the UpdateProviderGatewayOptions model updateProviderGatewayOptionsModel := new(directlinkproviderv2.UpdateProviderGatewayOptions) updateProviderGatewayOptionsModel.ID = core.StringPtr("testString") + updateProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateProviderGatewayOptionsModel.Name = core.StringPtr("myNewGateway") updateProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -719,36 +1214,132 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`UpdateProviderGateway(updateProviderGatewayOptions *UpdateProviderGatewayOptions)`, func() { version := "testString" updateProviderGatewayPath := "/gateways/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(updateProviderGatewayPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateProviderGatewayPath)) Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + })) + }) + It(`Invoke UpdateProviderGateway successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the UpdateProviderGatewayOptions model + updateProviderGatewayOptionsModel := new(directlinkproviderv2.UpdateProviderGatewayOptions) + updateProviderGatewayOptionsModel.ID = core.StringPtr("testString") + updateProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") + updateProviderGatewayOptionsModel.Name = core.StringPtr("myNewGateway") + updateProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) + updateProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.UpdateProviderGatewayWithContext(ctx, updateProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.UpdateProviderGatewayWithContext(ctx, updateProviderGatewayOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateProviderGatewayPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00", "crn": "crn:v1:bluemix:public:directlink:dal03:a/57a7d05f36894e3cb9b46a43556d903e::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "57a7d05f36894e3cb9b46a43556d903e", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "create_pending", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"bgp_asn": 64999, "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "change_request": {"type": "create_gateway"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::connect:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "customer_account_id": "4111d05f36894e3cb9b46a43556d9000", "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "name": "myGateway", "operational_status": "configuring", "port": {"id": "fffdcb1a-fee4-41c7-9e11-9cd99e65c777"}, "provider_api_managed": true, "speed_mbps": 1000, "type": "connect", "vlan": 10}`) })) }) It(`Invoke UpdateProviderGateway successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.UpdateProviderGateway(nil) + result, response, operationErr := directLinkProviderService.UpdateProviderGateway(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -756,35 +1347,42 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the UpdateProviderGatewayOptions model updateProviderGatewayOptionsModel := new(directlinkproviderv2.UpdateProviderGatewayOptions) updateProviderGatewayOptionsModel.ID = core.StringPtr("testString") + updateProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateProviderGatewayOptionsModel.Name = core.StringPtr("myNewGateway") updateProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + result, response, operationErr = directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke UpdateProviderGateway with error: Operation validation and request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the UpdateProviderGatewayOptions model updateProviderGatewayOptionsModel := new(directlinkproviderv2.UpdateProviderGatewayOptions) updateProviderGatewayOptionsModel.ID = core.StringPtr("testString") + updateProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateProviderGatewayOptionsModel.Name = core.StringPtr("myNewGateway") updateProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + result, response, operationErr := directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -792,7 +1390,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct a second instance of the UpdateProviderGatewayOptions model with no property values updateProviderGatewayOptionsModelNew := new(directlinkproviderv2.UpdateProviderGatewayOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = testService.UpdateProviderGateway(updateProviderGatewayOptionsModelNew) + result, response, operationErr = directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -801,45 +1399,89 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateProviderGateway successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the UpdateProviderGatewayOptions model + updateProviderGatewayOptionsModel := new(directlinkproviderv2.UpdateProviderGatewayOptions) + updateProviderGatewayOptionsModel.ID = core.StringPtr("testString") + updateProviderGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateProviderGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateProviderGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") + updateProviderGatewayOptionsModel.Name = core.StringPtr("myNewGateway") + updateProviderGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) + updateProviderGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.UpdateProviderGateway(updateProviderGatewayOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`ListProviderPorts(listProviderPortsOptions *ListProviderPortsOptions) - Operation response error`, func() { version := "testString" listProviderPortsPath := "/ports" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(listProviderPortsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listProviderPortsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(38))})) - + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke ListProviderPorts with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ListProviderPortsOptions model listProviderPortsOptionsModel := new(directlinkproviderv2.ListProviderPortsOptions) listProviderPortsOptionsModel.Start = core.StringPtr("testString") - listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderPortsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.ListProviderPorts(listProviderPortsOptionsModel) + result, response, operationErr := directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -849,40 +1491,100 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`ListProviderPorts(listProviderPortsOptions *ListProviderPortsOptions)`, func() { version := "testString" listProviderPortsPath := "/ports" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(listProviderPortsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listProviderPortsPath)) Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}]}`) + })) + }) + It(`Invoke ListProviderPorts successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(38))})) + // Construct an instance of the ListProviderPortsOptions model + listProviderPortsOptionsModel := new(directlinkproviderv2.ListProviderPortsOptions) + listProviderPortsOptionsModel.Start = core.StringPtr("testString") + listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listProviderPortsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.ListProviderPortsWithContext(ctx, listProviderPortsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.ListProviderPortsWithContext(ctx, listProviderPortsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listProviderPortsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?limit=100"}, "limit": 100, "next": {"href": "https://directlink.cloud.ibm.com/provider/v2/ports?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=100", "start": "9d5a91a3e2cbd233b5a5b33436855ed1"}, "total_count": 132, "ports": [{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}]}`) })) }) It(`Invoke ListProviderPorts successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.ListProviderPorts(nil) + result, response, operationErr := directLinkProviderService.ListProviderPorts(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -890,33 +1592,34 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the ListProviderPortsOptions model listProviderPortsOptionsModel := new(directlinkproviderv2.ListProviderPortsOptions) listProviderPortsOptionsModel.Start = core.StringPtr("testString") - listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderPortsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.ListProviderPorts(listProviderPortsOptionsModel) + result, response, operationErr = directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke ListProviderPorts with error: Operation request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the ListProviderPortsOptions model listProviderPortsOptionsModel := new(directlinkproviderv2.ListProviderPortsOptions) listProviderPortsOptionsModel.Start = core.StringPtr("testString") - listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(38)) + listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(1)) listProviderPortsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.ListProviderPorts(listProviderPortsOptionsModel) + result, response, operationErr := directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -926,40 +1629,82 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListProviderPorts successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the ListProviderPortsOptions model + listProviderPortsOptionsModel := new(directlinkproviderv2.ListProviderPortsOptions) + listProviderPortsOptionsModel.Start = core.StringPtr("testString") + listProviderPortsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listProviderPortsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.ListProviderPorts(listProviderPortsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`GetProviderPort(getProviderPortOptions *GetProviderPortOptions) - Operation response error`, func() { version := "testString" getProviderPortPath := "/ports/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(getProviderPortPath)) + Expect(req.URL.EscapedPath()).To(Equal(getProviderPortPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprintf(res, `} this is not valid json {`) })) }) It(`Invoke GetProviderPort with error: Operation response processing error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the GetProviderPortOptions model getProviderPortOptionsModel := new(directlinkproviderv2.GetProviderPortOptions) getProviderPortOptionsModel.ID = core.StringPtr("testString") getProviderPortOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := testService.GetProviderPort(getProviderPortOptionsModel) + result, response, operationErr := directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkProviderService.EnableRetries(0, 0) + result, response, operationErr = directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -969,36 +1714,95 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) }) }) - Describe(`GetProviderPort(getProviderPortOptions *GetProviderPortOptions)`, func() { version := "testString" getProviderPortPath := "/ports/testString" - Context(`Using mock server endpoint`, func() { + Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(getProviderPortPath)) + Expect(req.URL.EscapedPath()).To(Equal(getProviderPortPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}`) + })) + }) + It(`Invoke GetProviderPort successfully with retries`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + directLinkProviderService.EnableRetries(0, 0) + + // Construct an instance of the GetProviderPortOptions model + getProviderPortOptionsModel := new(directlinkproviderv2.GetProviderPortOptions) + getProviderPortOptionsModel.ID = core.StringPtr("testString") + getProviderPortOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkProviderService.GetProviderPortWithContext(ctx, getProviderPortOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkProviderService.DisableRetries() + result, response, operationErr := directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkProviderService.GetProviderPortWithContext(ctx, getProviderPortOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getProviderPortPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}`) + fmt.Fprintf(res, "%s", `{"id": "01122b9b-820f-4c44-8a31-77f1f0806765", "label": "XCR-FRK-CS-SEC-01", "location_display_name": "Dallas 03", "location_name": "dal03", "provider_name": "provider_1", "supported_link_speeds": [19]}`) })) }) It(`Invoke GetProviderPort successfully`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := testService.GetProviderPort(nil) + result, response, operationErr := directLinkProviderService.GetProviderPort(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1009,28 +1813,29 @@ var _ = Describe(`DirectLinkProviderV2`, func() { getProviderPortOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = testService.GetProviderPort(getProviderPortOptionsModel) + result, response, operationErr = directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + }) It(`Invoke GetProviderPort with error: Operation validation and request error`, func() { - testService, testServiceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), }) - Expect(testServiceErr).To(BeNil()) - Expect(testService).ToNot(BeNil()) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) // Construct an instance of the GetProviderPortOptions model getProviderPortOptionsModel := new(directlinkproviderv2.GetProviderPortOptions) getProviderPortOptionsModel.ID = core.StringPtr("testString") getProviderPortOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) - err := testService.SetServiceURL("") + err := directLinkProviderService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := testService.GetProviderPort(getProviderPortOptionsModel) + result, response, operationErr := directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -1038,7 +1843,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct a second instance of the GetProviderPortOptions model with no property values getProviderPortOptionsModelNew := new(directlinkproviderv2.GetProviderPortOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = testService.GetProviderPort(getProviderPortOptionsModelNew) + result, response, operationErr = directLinkProviderService.GetProviderPort(getProviderPortOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1047,11 +1852,46 @@ var _ = Describe(`DirectLinkProviderV2`, func() { testServer.Close() }) }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetProviderPort successfully`, func() { + directLinkProviderService, serviceErr := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkProviderService).ToNot(BeNil()) + + // Construct an instance of the GetProviderPortOptions model + getProviderPortOptionsModel := new(directlinkproviderv2.GetProviderPortOptions) + getProviderPortOptionsModel.ID = core.StringPtr("testString") + getProviderPortOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkProviderService.GetProviderPort(getProviderPortOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { version := "testString" - testService, _ := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ + directLinkProviderService, _ := directlinkproviderv2.NewDirectLinkProviderV2(&directlinkproviderv2.DirectLinkProviderV2Options{ URL: "http://directlinkproviderv2modelgenerator.com", Authenticator: &core.NoAuthAuthenticator{}, Version: core.StringPtr(version), @@ -1065,13 +1905,13 @@ var _ = Describe(`DirectLinkProviderV2`, func() { // Construct an instance of the CreateProviderGatewayOptions model createProviderGatewayOptionsBgpAsn := int64(64999) - createProviderGatewayOptionsCustomerAccountID := "57a7d05f36894e3cb9b46a43556d903e" + createProviderGatewayOptionsCustomerAccountID := "4111d05f36894e3cb9b46a43556d9000" createProviderGatewayOptionsName := "myGateway" var createProviderGatewayOptionsPort *directlinkproviderv2.ProviderGatewayPortIdentity = nil createProviderGatewayOptionsSpeedMbps := int64(1000) - createProviderGatewayOptionsModel := testService.NewCreateProviderGatewayOptions(createProviderGatewayOptionsBgpAsn, createProviderGatewayOptionsCustomerAccountID, createProviderGatewayOptionsName, createProviderGatewayOptionsPort, createProviderGatewayOptionsSpeedMbps) + createProviderGatewayOptionsModel := directLinkProviderService.NewCreateProviderGatewayOptions(createProviderGatewayOptionsBgpAsn, createProviderGatewayOptionsCustomerAccountID, createProviderGatewayOptionsName, createProviderGatewayOptionsPort, createProviderGatewayOptionsSpeedMbps) createProviderGatewayOptionsModel.SetBgpAsn(int64(64999)) - createProviderGatewayOptionsModel.SetCustomerAccountID("57a7d05f36894e3cb9b46a43556d903e") + createProviderGatewayOptionsModel.SetCustomerAccountID("4111d05f36894e3cb9b46a43556d9000") createProviderGatewayOptionsModel.SetName("myGateway") createProviderGatewayOptionsModel.SetPort(providerGatewayPortIdentityModel) createProviderGatewayOptionsModel.SetSpeedMbps(int64(1000)) @@ -1081,7 +1921,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { createProviderGatewayOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createProviderGatewayOptionsModel).ToNot(BeNil()) Expect(createProviderGatewayOptionsModel.BgpAsn).To(Equal(core.Int64Ptr(int64(64999)))) - Expect(createProviderGatewayOptionsModel.CustomerAccountID).To(Equal(core.StringPtr("57a7d05f36894e3cb9b46a43556d903e"))) + Expect(createProviderGatewayOptionsModel.CustomerAccountID).To(Equal(core.StringPtr("4111d05f36894e3cb9b46a43556d9000"))) Expect(createProviderGatewayOptionsModel.Name).To(Equal(core.StringPtr("myGateway"))) Expect(createProviderGatewayOptionsModel.Port).To(Equal(providerGatewayPortIdentityModel)) Expect(createProviderGatewayOptionsModel.SpeedMbps).To(Equal(core.Int64Ptr(int64(1000)))) @@ -1093,7 +1933,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { It(`Invoke NewDeleteProviderGatewayOptions successfully`, func() { // Construct an instance of the DeleteProviderGatewayOptions model id := "testString" - deleteProviderGatewayOptionsModel := testService.NewDeleteProviderGatewayOptions(id) + deleteProviderGatewayOptionsModel := directLinkProviderService.NewDeleteProviderGatewayOptions(id) deleteProviderGatewayOptionsModel.SetID("testString") deleteProviderGatewayOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteProviderGatewayOptionsModel).ToNot(BeNil()) @@ -1103,7 +1943,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { It(`Invoke NewGetProviderGatewayOptions successfully`, func() { // Construct an instance of the GetProviderGatewayOptions model id := "testString" - getProviderGatewayOptionsModel := testService.NewGetProviderGatewayOptions(id) + getProviderGatewayOptionsModel := directLinkProviderService.NewGetProviderGatewayOptions(id) getProviderGatewayOptionsModel.SetID("testString") getProviderGatewayOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(getProviderGatewayOptionsModel).ToNot(BeNil()) @@ -1113,7 +1953,7 @@ var _ = Describe(`DirectLinkProviderV2`, func() { It(`Invoke NewGetProviderPortOptions successfully`, func() { // Construct an instance of the GetProviderPortOptions model id := "testString" - getProviderPortOptionsModel := testService.NewGetProviderPortOptions(id) + getProviderPortOptionsModel := directLinkProviderService.NewGetProviderPortOptions(id) getProviderPortOptionsModel.SetID("testString") getProviderPortOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(getProviderPortOptionsModel).ToNot(BeNil()) @@ -1122,42 +1962,48 @@ var _ = Describe(`DirectLinkProviderV2`, func() { }) It(`Invoke NewListProviderGatewaysOptions successfully`, func() { // Construct an instance of the ListProviderGatewaysOptions model - listProviderGatewaysOptionsModel := testService.NewListProviderGatewaysOptions() + listProviderGatewaysOptionsModel := directLinkProviderService.NewListProviderGatewaysOptions() listProviderGatewaysOptionsModel.SetStart("testString") - listProviderGatewaysOptionsModel.SetLimit(int64(38)) + listProviderGatewaysOptionsModel.SetLimit(int64(1)) listProviderGatewaysOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listProviderGatewaysOptionsModel).ToNot(BeNil()) Expect(listProviderGatewaysOptionsModel.Start).To(Equal(core.StringPtr("testString"))) - Expect(listProviderGatewaysOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(38)))) + Expect(listProviderGatewaysOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1)))) Expect(listProviderGatewaysOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListProviderPortsOptions successfully`, func() { // Construct an instance of the ListProviderPortsOptions model - listProviderPortsOptionsModel := testService.NewListProviderPortsOptions() + listProviderPortsOptionsModel := directLinkProviderService.NewListProviderPortsOptions() listProviderPortsOptionsModel.SetStart("testString") - listProviderPortsOptionsModel.SetLimit(int64(38)) + listProviderPortsOptionsModel.SetLimit(int64(1)) listProviderPortsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listProviderPortsOptionsModel).ToNot(BeNil()) Expect(listProviderPortsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) - Expect(listProviderPortsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(38)))) + Expect(listProviderPortsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1)))) Expect(listProviderPortsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewProviderGatewayPortIdentity successfully`, func() { id := "fffdcb1a-fee4-41c7-9e11-9cd99e65c777" - model, err := testService.NewProviderGatewayPortIdentity(id) + model, err := directLinkProviderService.NewProviderGatewayPortIdentity(id) Expect(model).ToNot(BeNil()) Expect(err).To(BeNil()) }) It(`Invoke NewUpdateProviderGatewayOptions successfully`, func() { // Construct an instance of the UpdateProviderGatewayOptions model id := "testString" - updateProviderGatewayOptionsModel := testService.NewUpdateProviderGatewayOptions(id) + updateProviderGatewayOptionsModel := directLinkProviderService.NewUpdateProviderGatewayOptions(id) updateProviderGatewayOptionsModel.SetID("testString") + updateProviderGatewayOptionsModel.SetBgpAsn(int64(64999)) + updateProviderGatewayOptionsModel.SetBgpCerCidr("169.254.0.10/30") + updateProviderGatewayOptionsModel.SetBgpIbmCidr("169.254.0.9/30") updateProviderGatewayOptionsModel.SetName("myNewGateway") updateProviderGatewayOptionsModel.SetSpeedMbps(int64(1000)) updateProviderGatewayOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateProviderGatewayOptionsModel).ToNot(BeNil()) Expect(updateProviderGatewayOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(updateProviderGatewayOptionsModel.BgpAsn).To(Equal(core.Int64Ptr(int64(64999)))) + Expect(updateProviderGatewayOptionsModel.BgpCerCidr).To(Equal(core.StringPtr("169.254.0.10/30"))) + Expect(updateProviderGatewayOptionsModel.BgpIbmCidr).To(Equal(core.StringPtr("169.254.0.9/30"))) Expect(updateProviderGatewayOptionsModel.Name).To(Equal(core.StringPtr("myNewGateway"))) Expect(updateProviderGatewayOptionsModel.SpeedMbps).To(Equal(core.Int64Ptr(int64(1000)))) Expect(updateProviderGatewayOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) @@ -1178,11 +2024,11 @@ var _ = Describe(`DirectLinkProviderV2`, func() { Expect(mockReader).ToNot(BeNil()) }) It(`Invoke CreateMockDate() successfully`, func() { - mockDate := CreateMockDate() + mockDate := CreateMockDate("2019-01-01") Expect(mockDate).ToNot(BeNil()) }) It(`Invoke CreateMockDateTime() successfully`, func() { - mockDateTime := CreateMockDateTime() + mockDateTime := CreateMockDateTime("2019-01-01T12:00:00.000Z") Expect(mockDateTime).ToNot(BeNil()) }) }) @@ -1207,13 +2053,19 @@ func CreateMockReader(mockData string) io.ReadCloser { return ioutil.NopCloser(bytes.NewReader([]byte(mockData))) } -func CreateMockDate() *strfmt.Date { - d := strfmt.Date(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)) +func CreateMockDate(mockData string) *strfmt.Date { + d, err := core.ParseDate(mockData) + if err != nil { + return nil + } return &d } -func CreateMockDateTime() *strfmt.DateTime { - d := strfmt.DateTime(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)) +func CreateMockDateTime(mockData string) *strfmt.DateTime { + d, err := core.ParseDateTime(mockData) + if err != nil { + return nil + } return &d } diff --git a/directlinkv1/direct_link_v1.go b/directlinkv1/direct_link_v1.go index ffd7d3a..c415596 100644 --- a/directlinkv1/direct_link_v1.go +++ b/directlinkv1/direct_link_v1.go @@ -453,6 +453,18 @@ func (directLink *DirectLinkV1) UpdateGatewayWithContext(ctx context.Context, up if updateGatewayOptions.AuthenticationKey != nil { body["authentication_key"] = updateGatewayOptions.AuthenticationKey } + if updateGatewayOptions.BfdConfig != nil { + body["bfd_config"] = updateGatewayOptions.BfdConfig + } + if updateGatewayOptions.BgpAsn != nil { + body["bgp_asn"] = updateGatewayOptions.BgpAsn + } + if updateGatewayOptions.BgpCerCidr != nil { + body["bgp_cer_cidr"] = updateGatewayOptions.BgpCerCidr + } + if updateGatewayOptions.BgpIbmCidr != nil { + body["bgp_ibm_cidr"] = updateGatewayOptions.BgpIbmCidr + } if updateGatewayOptions.ConnectionMode != nil { body["connection_mode"] = updateGatewayOptions.ConnectionMode } @@ -474,6 +486,9 @@ func (directLink *DirectLinkV1) UpdateGatewayWithContext(ctx context.Context, up if updateGatewayOptions.OperationalStatus != nil { body["operational_status"] = updateGatewayOptions.OperationalStatus } + if updateGatewayOptions.PatchPanelCompletionNotice != nil { + body["patch_panel_completion_notice"] = updateGatewayOptions.PatchPanelCompletionNotice + } if updateGatewayOptions.SpeedMbps != nil { body["speed_mbps"] = updateGatewayOptions.SpeedMbps } @@ -555,6 +570,9 @@ func (directLink *DirectLinkV1) CreateGatewayActionWithContext(ctx context.Conte if createGatewayActionOptions.AuthenticationKey != nil { body["authentication_key"] = createGatewayActionOptions.AuthenticationKey } + if createGatewayActionOptions.BfdConfig != nil { + body["bfd_config"] = createGatewayActionOptions.BfdConfig + } if createGatewayActionOptions.ConnectionMode != nil { body["connection_mode"] = createGatewayActionOptions.ConnectionMode } @@ -757,9 +775,9 @@ func (directLink *DirectLinkV1) ListGatewayLetterOfAuthorizationWithContext(ctx return } -// GetGatewayStatistics : Gateway statistics -// Retrieve gateway statistics. Specify statistic to retrieve using required `type` query parameter. Currently data -// retrieval is only supported for MACsec configurations. +// GetGatewayStatistics : Gateway statistics/debug information +// Retrieve gateway statistics or debug information. Specify statistic to retrieve using required `type` query +// parameter. func (directLink *DirectLinkV1) GetGatewayStatistics(getGatewayStatisticsOptions *GetGatewayStatisticsOptions) (result *GatewayStatisticCollection, response *core.DetailedResponse, err error) { return directLink.GetGatewayStatisticsWithContext(context.Background(), getGatewayStatisticsOptions) } @@ -821,6 +839,71 @@ func (directLink *DirectLinkV1) GetGatewayStatisticsWithContext(ctx context.Cont return } +// GetGatewayStatus : Gateway status information +// Retrieve gateway status. Specify status to retrieve using required `type` query parameter. +func (directLink *DirectLinkV1) GetGatewayStatus(getGatewayStatusOptions *GetGatewayStatusOptions) (result *GatewayStatusCollection, response *core.DetailedResponse, err error) { + return directLink.GetGatewayStatusWithContext(context.Background(), getGatewayStatusOptions) +} + +// GetGatewayStatusWithContext is an alternate form of the GetGatewayStatus method which supports a Context parameter +func (directLink *DirectLinkV1) GetGatewayStatusWithContext(ctx context.Context, getGatewayStatusOptions *GetGatewayStatusOptions) (result *GatewayStatusCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getGatewayStatusOptions, "getGatewayStatusOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getGatewayStatusOptions, "getGatewayStatusOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *getGatewayStatusOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = directLink.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(directLink.Service.Options.URL, `/gateways/{id}/status`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getGatewayStatusOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("direct_link", "V1", "GetGatewayStatus") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("version", fmt.Sprint(*directLink.Version)) + if getGatewayStatusOptions.Type != nil { + builder.AddQuery("type", fmt.Sprint(*getGatewayStatusOptions.Type)) + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = directLink.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalGatewayStatusCollection) + if err != nil { + return + } + response.Result = result + } + + return +} + // ListOfferingTypeLocations : List available locations // Retrieve the list of valid locations for the specified Direct Link offering. func (directLink *DirectLinkV1) ListOfferingTypeLocations(listOfferingTypeLocationsOptions *ListOfferingTypeLocationsOptions) (result *LocationCollection, response *core.DetailedResponse, err error) { @@ -1473,22 +1556,27 @@ type CreateGatewayActionOptions struct { // Action request. Action *string `validate:"required"` - // The identity of the standard key to use for BGP MD5 authentication key. + // Applicable for create_gateway_approve requests to select the gateway's BGP MD5 authentication key. // The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in // length. // To clear the optional `authentication_key` field patch its crn to `""`. AuthenticationKey *GatewayActionTemplateAuthenticationKey - // Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway - // Service and direct means this Gateway will be attached to vpc or classic connection. The list of enumerated values - // for this property may expand in the future. Code and processes using this field must tolerate unexpected values. + // Applicable for create_gateway_approve requests to select the gateway's BFD configuration information. + BfdConfig *GatewayBfdConfigActionTemplate + + // Applicable for create_gateway_approve requests to select the type of services this gateway is attached to. Mode + // transit indicates this gateway will be attached to Transit Gateway Service and direct means this gateway will be + // attached to vpc or classic connection. If unspecified on create_gateway_approve, default value direct is used. The + // list of enumerated values for this property may expand in the future. Code and processes using this field must + // tolerate unexpected values. ConnectionMode *string - // Required for create_gateway_approve requests to select the gateway's routing option. Gateways with global routing + // Applicable for create_gateway_approve requests to select the gateway's routing option. Gateways with global routing // (`true`) can connect to networks outside of their associated region. Global *bool - // Required for create_gateway_approve requests to select the gateway's metered billing option. When `true` gateway + // Applicable for create_gateway_approve requests to select the gateway's metered billing option. When `true` gateway // usage is billed per gigabyte. When `false` there is no per gigabyte usage charge, instead a flat rate is charged // for the gateway. Metered *bool @@ -1518,9 +1606,11 @@ const ( ) // Constants associated with the CreateGatewayActionOptions.ConnectionMode property. -// Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway -// Service and direct means this Gateway will be attached to vpc or classic connection. The list of enumerated values -// for this property may expand in the future. Code and processes using this field must tolerate unexpected values. +// Applicable for create_gateway_approve requests to select the type of services this gateway is attached to. Mode +// transit indicates this gateway will be attached to Transit Gateway Service and direct means this gateway will be +// attached to vpc or classic connection. If unspecified on create_gateway_approve, default value direct is used. The +// list of enumerated values for this property may expand in the future. Code and processes using this field must +// tolerate unexpected values. const ( CreateGatewayActionOptions_ConnectionMode_Direct = "direct" CreateGatewayActionOptions_ConnectionMode_Transit = "transit" @@ -1552,6 +1642,12 @@ func (options *CreateGatewayActionOptions) SetAuthenticationKey(authenticationKe return options } +// SetBfdConfig : Allow user to set BfdConfig +func (options *CreateGatewayActionOptions) SetBfdConfig(bfdConfig *GatewayBfdConfigActionTemplate) *CreateGatewayActionOptions { + options.BfdConfig = bfdConfig + return options +} + // SetConnectionMode : Allow user to set ConnectionMode func (options *CreateGatewayActionOptions) SetConnectionMode(connectionMode string) *CreateGatewayActionOptions { options.ConnectionMode = core.StringPtr(connectionMode) @@ -1833,6 +1929,9 @@ type Gateway struct { // To clear the optional `authentication_key` field patch its crn to `""`. AuthenticationKey *GatewayAuthenticationKey `json:"authentication_key,omitempty"` + // BFD configuration information. + BfdConfig *GatewayBfdConfig `json:"bfd_config,omitempty"` + // Customer BGP ASN. BgpAsn *int64 `json:"bgp_asn" validate:"required"` @@ -1856,6 +1955,9 @@ type Gateway struct { // using this field must tolerate unexpected values. BgpStatus *string `json:"bgp_status,omitempty"` + // Date and time bgp status was updated. + BgpStatusUpdatedAt *strfmt.DateTime `json:"bgp_status_updated_at,omitempty"` + // Carrier name. Only set for type=dedicated gateways. CarrierName *string `json:"carrier_name,omitempty"` @@ -1892,6 +1994,9 @@ type Gateway struct { // expand in the future. Code and processes using this field must tolerate unexpected values. LinkStatus *string `json:"link_status,omitempty"` + // Date and time link status was updated. + LinkStatusUpdatedAt *strfmt.DateTime `json:"link_status_updated_at,omitempty"` + // Gateway location long name. LocationDisplayName *string `json:"location_display_name" validate:"required"` @@ -1913,6 +2018,9 @@ type Gateway struct { // processes using this field must tolerate unexpected values. OperationalStatus *string `json:"operational_status" validate:"required"` + // Gateway patch panel complete notification from implementation team. + PatchPanelCompletionNotice *string `json:"patch_panel_completion_notice,omitempty"` + // gateway port for type=connect gateways. Port *GatewayPort `json:"port,omitempty"` @@ -1994,6 +2102,10 @@ func UnmarshalGateway(m map[string]json.RawMessage, result interface{}) (err err if err != nil { return } + err = core.UnmarshalModel(m, "bfd_config", &obj.BfdConfig, UnmarshalGatewayBfdConfig) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) if err != nil { return @@ -2018,6 +2130,10 @@ func UnmarshalGateway(m map[string]json.RawMessage, result interface{}) (err err if err != nil { return } + err = core.UnmarshalPrimitive(m, "bgp_status_updated_at", &obj.BgpStatusUpdatedAt) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "carrier_name", &obj.CarrierName) if err != nil { return @@ -2062,6 +2178,10 @@ func UnmarshalGateway(m map[string]json.RawMessage, result interface{}) (err err if err != nil { return } + err = core.UnmarshalPrimitive(m, "link_status_updated_at", &obj.LinkStatusUpdatedAt) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "location_display_name", &obj.LocationDisplayName) if err != nil { return @@ -2086,6 +2206,10 @@ func UnmarshalGateway(m map[string]json.RawMessage, result interface{}) (err err if err != nil { return } + err = core.UnmarshalPrimitive(m, "patch_panel_completion_notice", &obj.PatchPanelCompletionNotice) + if err != nil { + return + } err = core.UnmarshalModel(m, "port", &obj.Port, UnmarshalGatewayPort) if err != nil { return @@ -2114,9 +2238,9 @@ func UnmarshalGateway(m map[string]json.RawMessage, result interface{}) (err err return } -// GatewayActionTemplateAuthenticationKey : The identity of the standard key to use for BGP MD5 authentication key. The key material that you provide must be -// base64 encoded and original string must be maximum 126 ASCII characters in length. To clear the optional -// `authentication_key` field patch its crn to `""`. +// GatewayActionTemplateAuthenticationKey : Applicable for create_gateway_approve requests to select the gateway's BGP MD5 authentication key. The key material +// that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in length. To clear +// the optional `authentication_key` field patch its crn to `""`. type GatewayActionTemplateAuthenticationKey struct { // The CRN of the [Key Protect Standard // Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto @@ -2147,9 +2271,33 @@ func UnmarshalGatewayActionTemplateAuthenticationKey(m map[string]json.RawMessag // GatewayActionTemplateUpdatesItem : GatewayActionTemplateUpdatesItem struct // Models which "extend" this model: // - GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate +// - GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate +// - GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate type GatewayActionTemplateUpdatesItem struct { // New gateway speed in megabits per second. SpeedMbps *int64 `json:"speed_mbps,omitempty"` + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` + + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` } func (*GatewayActionTemplateUpdatesItem) isaGatewayActionTemplateUpdatesItem() bool { @@ -2167,6 +2315,18 @@ func UnmarshalGatewayActionTemplateUpdatesItem(m map[string]json.RawMessage, res if err != nil { return } + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -2192,6 +2352,150 @@ func UnmarshalGatewayAuthenticationKey(m map[string]json.RawMessage, result inte return } +// GatewayBfdConfig : BFD configuration information. +type GatewayBfdConfig struct { + // Gateway BFD status. The list of enumerated values for this property may expand in the future. Code and processes + // using this field must tolerate unexpected values. + BfdStatus *string `json:"bfd_status,omitempty"` + + // Date and time bfd status was updated. + BfdStatusUpdatedAt *strfmt.DateTime `json:"bfd_status_updated_at,omitempty"` + + // Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to + // receive a reply from a neighbor with which it has established a BFD session. + Interval *int64 `json:"interval" validate:"required"` + + // The number of hello packets not received by a neighbor that causes the originating interface to be declared down. + Multiplier *int64 `json:"multiplier" validate:"required"` +} + +// Constants associated with the GatewayBfdConfig.BfdStatus property. +// Gateway BFD status. The list of enumerated values for this property may expand in the future. Code and processes +// using this field must tolerate unexpected values. +const ( + GatewayBfdConfig_BfdStatus_Down = "down" + GatewayBfdConfig_BfdStatus_Init = "init" + GatewayBfdConfig_BfdStatus_Up = "up" +) + +// UnmarshalGatewayBfdConfig unmarshals an instance of GatewayBfdConfig from the specified map of raw messages. +func UnmarshalGatewayBfdConfig(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayBfdConfig) + err = core.UnmarshalPrimitive(m, "bfd_status", &obj.BfdStatus) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bfd_status_updated_at", &obj.BfdStatusUpdatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "multiplier", &obj.Multiplier) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayBfdConfigActionTemplate : Applicable for create_gateway_approve requests to select the gateway's BFD configuration information. +type GatewayBfdConfigActionTemplate struct { + // Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to + // receive a reply from a neighbor with which it has established a BFD session. + Interval *int64 `json:"interval" validate:"required"` + + // The number of hello packets not received by a neighbor that causes the originating interface to be declared down. + Multiplier *int64 `json:"multiplier,omitempty"` +} + +// NewGatewayBfdConfigActionTemplate : Instantiate GatewayBfdConfigActionTemplate (Generic Model Constructor) +func (*DirectLinkV1) NewGatewayBfdConfigActionTemplate(interval int64) (model *GatewayBfdConfigActionTemplate, err error) { + model = &GatewayBfdConfigActionTemplate{ + Interval: core.Int64Ptr(interval), + } + err = core.ValidateStruct(model, "required parameters") + return +} + +// UnmarshalGatewayBfdConfigActionTemplate unmarshals an instance of GatewayBfdConfigActionTemplate from the specified map of raw messages. +func UnmarshalGatewayBfdConfigActionTemplate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayBfdConfigActionTemplate) + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "multiplier", &obj.Multiplier) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayBfdConfigTemplate : BFD configuration information. +type GatewayBfdConfigTemplate struct { + // Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to + // receive a reply from a neighbor with which it has established a BFD session. + Interval *int64 `json:"interval" validate:"required"` + + // The number of hello packets not received by a neighbor that causes the originating interface to be declared down. + Multiplier *int64 `json:"multiplier,omitempty"` +} + +// NewGatewayBfdConfigTemplate : Instantiate GatewayBfdConfigTemplate (Generic Model Constructor) +func (*DirectLinkV1) NewGatewayBfdConfigTemplate(interval int64) (model *GatewayBfdConfigTemplate, err error) { + model = &GatewayBfdConfigTemplate{ + Interval: core.Int64Ptr(interval), + } + err = core.ValidateStruct(model, "required parameters") + return +} + +// UnmarshalGatewayBfdConfigTemplate unmarshals an instance of GatewayBfdConfigTemplate from the specified map of raw messages. +func UnmarshalGatewayBfdConfigTemplate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayBfdConfigTemplate) + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "multiplier", &obj.Multiplier) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayBfdPatchTemplate : BFD configuration information. +type GatewayBfdPatchTemplate struct { + // Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to + // receive a reply from a neighbor with which it has established a BFD session. + // + // To clear the BFD configuration patch its interval to 0. + Interval *int64 `json:"interval,omitempty"` + + // The number of hello packets not received by a neighbor that causes the originating interface to be declared down. + Multiplier *int64 `json:"multiplier,omitempty"` +} + +// UnmarshalGatewayBfdPatchTemplate unmarshals an instance of GatewayBfdPatchTemplate from the specified map of raw messages. +func UnmarshalGatewayBfdPatchTemplate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayBfdPatchTemplate) + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "multiplier", &obj.Multiplier) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // GatewayChangeRequest : GatewayChangeRequest struct // Models which "extend" this model: // - GatewayChangeRequestGatewayClientGatewayCreate @@ -2237,9 +2541,33 @@ func UnmarshalGatewayChangeRequest(m map[string]json.RawMessage, result interfac // GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem : GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem struct // Models which "extend" this model: // - GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate +// - GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate +// - GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate type GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem struct { // New gateway speed in megabits per second. SpeedMbps *int64 `json:"speed_mbps,omitempty"` + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` + + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` } func (*GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem) isaGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem() bool { @@ -2257,6 +2585,18 @@ func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesIte if err != nil { return } + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -2264,9 +2604,33 @@ func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesIte // GatewayChangeRequestUpdatesItem : GatewayChangeRequestUpdatesItem struct // Models which "extend" this model: // - GatewayChangeRequestUpdatesItemGatewayClientSpeedUpdate +// - GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate +// - GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate type GatewayChangeRequestUpdatesItem struct { // New gateway speed in megabits per second. SpeedMbps *int64 `json:"speed_mbps,omitempty"` + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` + + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` } func (*GatewayChangeRequestUpdatesItem) isaGatewayChangeRequestUpdatesItem() bool { @@ -2284,6 +2648,18 @@ func UnmarshalGatewayChangeRequestUpdatesItem(m map[string]json.RawMessage, resu if err != nil { return } + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -2818,7 +3194,7 @@ func UnmarshalGatewayPortIdentity(m map[string]json.RawMessage, result interface return } -// GatewayStatistic : Gateway statistics. Currently data retrieval is only supported for MACsec configurations. +// GatewayStatistic : Gateway statistics and debug commands. type GatewayStatistic struct { // Date and time data was collected. CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` @@ -2833,6 +3209,7 @@ type GatewayStatistic struct { // Constants associated with the GatewayStatistic.Type property. // statistic type. const ( + GatewayStatistic_Type_BfdSession = "bfd_session" GatewayStatistic_Type_MacsecMkaSession = "macsec_mka_session" GatewayStatistic_Type_MacsecMkaStatistics = "macsec_mka_statistics" GatewayStatistic_Type_MacsecPolicy = "macsec_policy" @@ -2874,45 +3251,122 @@ func UnmarshalGatewayStatisticCollection(m map[string]json.RawMessage, result in return } -// GatewayTemplate : Create gateway template. +// GatewayStatus : GatewayStatus struct // Models which "extend" this model: -// - GatewayTemplateGatewayTypeDedicatedTemplate -// - GatewayTemplateGatewayTypeConnectTemplate -type GatewayTemplate struct { - // The identity of the standard key to use for BGP MD5 authentication key. - // The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in - // length. - // To clear the optional `authentication_key` field patch its crn to `""`. - AuthenticationKey *GatewayTemplateAuthenticationKey `json:"authentication_key,omitempty"` +// - GatewayStatusGatewayBGPStatus +// - GatewayStatusGatewayBFDStatus +// - GatewayStatusGatewayLinkStatus +type GatewayStatus struct { + // Status type. + Type *string `json:"type,omitempty"` - // BGP ASN. - BgpAsn *int64 `json:"bgp_asn" validate:"required"` + // Date and time status was collected. + UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty"` - // (DEPRECATED) BGP base CIDR. - // - // Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to create a gateway using either - // automatic or explicit IP assignment. Any bgp_base_cidr value set will be ignored. - // - // Deprecated field bgp_base_cidr will be removed from the API specificiation after 15-MAR-2021. - BgpBaseCidr *string `json:"bgp_base_cidr,omitempty"` + // Status. + Value *string `json:"value,omitempty"` +} - // BGP customer edge router CIDR. - // - // For auto IP assignment, omit bgp_cer_cidr and bgp_ibm_cidr. IBM will automatically select values for bgp_cer_cidr - // and bgp_ibm_cidr. - // - // For explicit IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of - // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and - // bgp_ibm_cidr must have matching network and subnet mask values. - BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` +// Constants associated with the GatewayStatus.Type property. +// Status type. +const ( + GatewayStatus_Type_Bgp = "bgp" +) - // BGP IBM CIDR. - // - // For auto IP assignment, omit bgp_cer_cidr and bgp_ibm_cidr. IBM will automatically select values for bgp_cer_cidr - // and bgp_ibm_cidr. - // - // For explicit IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of - // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and +// Constants associated with the GatewayStatus.Value property. +// Status. +const ( + GatewayStatus_Value_Active = "active" + GatewayStatus_Value_Connect = "connect" + GatewayStatus_Value_Established = "established" + GatewayStatus_Value_Idle = "idle" +) + +func (*GatewayStatus) isaGatewayStatus() bool { + return true +} + +type GatewayStatusIntf interface { + isaGatewayStatus() bool +} + +// UnmarshalGatewayStatus unmarshals an instance of GatewayStatus from the specified map of raw messages. +func UnmarshalGatewayStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayStatus) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayStatusCollection : gateway status. +type GatewayStatusCollection struct { + Status []GatewayStatusIntf `json:"status,omitempty"` +} + +// UnmarshalGatewayStatusCollection unmarshals an instance of GatewayStatusCollection from the specified map of raw messages. +func UnmarshalGatewayStatusCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayStatusCollection) + err = core.UnmarshalModel(m, "status", &obj.Status, UnmarshalGatewayStatus) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayTemplate : Create gateway template. +// Models which "extend" this model: +// - GatewayTemplateGatewayTypeDedicatedTemplate +// - GatewayTemplateGatewayTypeConnectTemplate +type GatewayTemplate struct { + // The identity of the standard key to use for BGP MD5 authentication key. + // The key material that you provide must be base64 encoded and original string must be maximum 126 ASCII characters in + // length. + // To clear the optional `authentication_key` field patch its crn to `""`. + AuthenticationKey *GatewayTemplateAuthenticationKey `json:"authentication_key,omitempty"` + + // BFD configuration information. + BfdConfig *GatewayBfdConfigTemplate `json:"bfd_config,omitempty"` + + // BGP ASN. + BgpAsn *int64 `json:"bgp_asn" validate:"required"` + + // (DEPRECATED) BGP base CIDR. + // + // Field is deprecated. See bgp_ibm_cidr and bgp_cer_cidr for details on how to create a gateway using either + // automatic or explicit IP assignment. Any bgp_base_cidr value set will be ignored. + // + // Deprecated field bgp_base_cidr will be removed from the API specificiation after 15-MAR-2021. + BgpBaseCidr *string `json:"bgp_base_cidr,omitempty"` + + // BGP customer edge router CIDR. + // + // For auto IP assignment, omit bgp_cer_cidr and bgp_ibm_cidr. IBM will automatically select values for bgp_cer_cidr + // and bgp_ibm_cidr. + // + // For explicit IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of + // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and + // bgp_ibm_cidr must have matching network and subnet mask values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR. + // + // For auto IP assignment, omit bgp_cer_cidr and bgp_ibm_cidr. IBM will automatically select values for bgp_cer_cidr + // and bgp_ibm_cidr. + // + // For explicit IP assignment set a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must reside in one of + // "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and // bgp_ibm_cidr must have matching network and subnet mask values. BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` @@ -2931,6 +3385,9 @@ type GatewayTemplate struct { // The unique user-defined name for this gateway. Name *string `json:"name" validate:"required"` + // Gateway patch panel complete notification from implementation team. + PatchPanelCompletionNotice *string `json:"patch_panel_completion_notice,omitempty"` + // Resource group for this resource. If unspecified, the account's [default resource // group](https://cloud.ibm.com/apidocs/resource-manager#introduction) is used. ResourceGroup *ResourceGroupIdentity `json:"resource_group,omitempty"` @@ -2991,6 +3448,10 @@ func UnmarshalGatewayTemplate(m map[string]json.RawMessage, result interface{}) if err != nil { return } + err = core.UnmarshalModel(m, "bfd_config", &obj.BfdConfig, UnmarshalGatewayBfdConfigTemplate) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) if err != nil { return @@ -3023,6 +3484,10 @@ func UnmarshalGatewayTemplate(m map[string]json.RawMessage, result interface{}) if err != nil { return } + err = core.UnmarshalPrimitive(m, "patch_panel_completion_notice", &obj.PatchPanelCompletionNotice) + if err != nil { + return + } err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) if err != nil { return @@ -3149,6 +3614,7 @@ const ( // tolerate unexpected values. const ( GatewayVirtualConnection_Type_Classic = "classic" + GatewayVirtualConnection_Type_Transit = "transit" GatewayVirtualConnection_Type_Vpc = "vpc" ) @@ -3234,10 +3700,10 @@ func (options *GetGatewayOptions) SetHeaders(param map[string]string) *GetGatewa // GetGatewayStatisticsOptions : The GetGatewayStatistics options. type GetGatewayStatisticsOptions struct { - // Direct Link Dedicated gateway identifier. + // Direct Link gateway identifier. ID *string `validate:"required,ne="` - // specify statistic to retrieve. + // Specify statistic to retrieve. Type *string `validate:"required"` // Allows users to set headers on API requests @@ -3245,7 +3711,7 @@ type GetGatewayStatisticsOptions struct { } // Constants associated with the GetGatewayStatisticsOptions.Type property. -// specify statistic to retrieve. +// Specify statistic to retrieve. const ( GetGatewayStatisticsOptions_Type_MacsecMka = "macsec_mka" GetGatewayStatisticsOptions_Type_MacsecSecurity = "macsec_security" @@ -3277,6 +3743,51 @@ func (options *GetGatewayStatisticsOptions) SetHeaders(param map[string]string) return options } +// GetGatewayStatusOptions : The GetGatewayStatus options. +type GetGatewayStatusOptions struct { + // Direct Link gateway identifier. + ID *string `validate:"required,ne="` + + // Specify status to retrieve. + Type *string + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the GetGatewayStatusOptions.Type property. +// Specify status to retrieve. +const ( + GetGatewayStatusOptions_Type_Bfd = "bfd" + GetGatewayStatusOptions_Type_Bgp = "bgp" + GetGatewayStatusOptions_Type_Link = "link" +) + +// NewGetGatewayStatusOptions : Instantiate GetGatewayStatusOptions +func (*DirectLinkV1) NewGetGatewayStatusOptions(id string) *GetGatewayStatusOptions { + return &GetGatewayStatusOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (options *GetGatewayStatusOptions) SetID(id string) *GetGatewayStatusOptions { + options.ID = core.StringPtr(id) + return options +} + +// SetType : Allow user to set Type +func (options *GetGatewayStatusOptions) SetType(typeVar string) *GetGatewayStatusOptions { + options.Type = core.StringPtr(typeVar) + return options +} + +// SetHeaders : Allow user to set Headers +func (options *GetGatewayStatusOptions) SetHeaders(param map[string]string) *GetGatewayStatusOptions { + options.Headers = param + return options +} + // GetGatewayVirtualConnectionOptions : The GetGatewayVirtualConnection options. type GetGatewayVirtualConnectionOptions struct { // Direct Link gateway identifier. @@ -3981,6 +4492,31 @@ type UpdateGatewayOptions struct { // To clear the optional `authentication_key` field patch its crn to `""`. AuthenticationKey *GatewayPatchTemplateAuthenticationKey + // BFD configuration information. + BfdConfig *GatewayBfdPatchTemplate + + // The autonomous system number (ASN) of Border Gateway Protocol (BGP) configuration for the IBM side of the DL 2.0 + // gateway. + BgpAsn *int64 + + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public + // CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpCerCidr *string + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string + // Type of services this Gateway is attached to. Mode transit means this Gateway will be attached to Transit Gateway // Service and direct means this Gateway will be attached to vpc or classic connection. The list of enumerated values // for this property may expand in the future. Code and processes using this field must tolerate unexpected values. @@ -4015,6 +4551,9 @@ type UpdateGatewayOptions struct { // Only allowed for type=dedicated gateways. OperationalStatus *string + // Gateway patch panel complete notification from implementation team. + PatchPanelCompletionNotice *string + // Gateway speed in megabits per second. SpeedMbps *int64 @@ -4062,6 +4601,30 @@ func (options *UpdateGatewayOptions) SetAuthenticationKey(authenticationKey *Gat return options } +// SetBfdConfig : Allow user to set BfdConfig +func (options *UpdateGatewayOptions) SetBfdConfig(bfdConfig *GatewayBfdPatchTemplate) *UpdateGatewayOptions { + options.BfdConfig = bfdConfig + return options +} + +// SetBgpAsn : Allow user to set BgpAsn +func (options *UpdateGatewayOptions) SetBgpAsn(bgpAsn int64) *UpdateGatewayOptions { + options.BgpAsn = core.Int64Ptr(bgpAsn) + return options +} + +// SetBgpCerCidr : Allow user to set BgpCerCidr +func (options *UpdateGatewayOptions) SetBgpCerCidr(bgpCerCidr string) *UpdateGatewayOptions { + options.BgpCerCidr = core.StringPtr(bgpCerCidr) + return options +} + +// SetBgpIbmCidr : Allow user to set BgpIbmCidr +func (options *UpdateGatewayOptions) SetBgpIbmCidr(bgpIbmCidr string) *UpdateGatewayOptions { + options.BgpIbmCidr = core.StringPtr(bgpIbmCidr) + return options +} + // SetConnectionMode : Allow user to set ConnectionMode func (options *UpdateGatewayOptions) SetConnectionMode(connectionMode string) *UpdateGatewayOptions { options.ConnectionMode = core.StringPtr(connectionMode) @@ -4104,6 +4667,12 @@ func (options *UpdateGatewayOptions) SetOperationalStatus(operationalStatus stri return options } +// SetPatchPanelCompletionNotice : Allow user to set PatchPanelCompletionNotice +func (options *UpdateGatewayOptions) SetPatchPanelCompletionNotice(patchPanelCompletionNotice string) *UpdateGatewayOptions { + options.PatchPanelCompletionNotice = core.StringPtr(patchPanelCompletionNotice) + return options +} + // SetSpeedMbps : Allow user to set SpeedMbps func (options *UpdateGatewayOptions) SetSpeedMbps(speedMbps int64) *UpdateGatewayOptions { options.SpeedMbps = core.Int64Ptr(speedMbps) @@ -4184,6 +4753,71 @@ func (options *UpdateGatewayVirtualConnectionOptions) SetHeaders(param map[strin return options } +// GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate : The autonomous system number (ASN) of Border Gateway Protocol +// (BGP) configuration for the IBM side of the DL 2.0 gateway. +// This model "extends" GatewayActionTemplateUpdatesItem +type GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate struct { + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` +} + +func (*GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate) isaGatewayActionTemplateUpdatesItem() bool { + return true +} + +// UnmarshalGatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate unmarshals an instance of GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate from the specified map of raw messages. +func UnmarshalGatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayActionTemplateUpdatesItemGatewayClientBGPASNUpdate) + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate : Update BGP customer and IBM CIDR. +// This model "extends" GatewayActionTemplateUpdatesItem +type GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate struct { + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` +} + +func (*GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate) isaGatewayActionTemplateUpdatesItem() bool { + return true +} + +// UnmarshalGatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate unmarshals an instance of GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate from the specified map of raw messages. +func UnmarshalGatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayActionTemplateUpdatesItemGatewayClientBGPIPUpdate) + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate : gateway speed change. // This model "extends" GatewayActionTemplateUpdatesItem type GatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate struct { @@ -4206,6 +4840,71 @@ func UnmarshalGatewayActionTemplateUpdatesItemGatewayClientSpeedUpdate(m map[str return } +// GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate : The autonomous system number (ASN) of Border Gateway Protocol +// (BGP) configuration for the IBM side of the DL 2.0 gateway. +// This model "extends" GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem +type GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate struct { + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` +} + +func (*GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate) isaGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem() bool { + return true +} + +// UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate unmarshals an instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate from the specified map of raw messages. +func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPASNUpdate) + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate : Update BGP customer and IBM CIDR. +// This model "extends" GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem +type GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate struct { + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` +} + +func (*GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate) isaGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem() bool { + return true +} + +// UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate unmarshals an instance of GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate from the specified map of raw messages. +func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientBGPIPUpdate) + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate : gateway speed change. // This model "extends" GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItem type GatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesItemGatewayClientSpeedUpdate struct { @@ -4228,6 +4927,71 @@ func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributesUpdatesIte return } +// GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate : The autonomous system number (ASN) of Border Gateway Protocol +// (BGP) configuration for the IBM side of the DL 2.0 gateway. +// This model "extends" GatewayChangeRequestUpdatesItem +type GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate struct { + // New gateway BGP ASN. + BgpAsn *int64 `json:"bgp_asn,omitempty"` +} + +func (*GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate) isaGatewayChangeRequestUpdatesItem() bool { + return true +} + +// UnmarshalGatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate unmarshals an instance of GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate from the specified map of raw messages. +func UnmarshalGatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayChangeRequestUpdatesItemGatewayClientBGPASNUpdate) + err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate : Update BGP customer and IBM CIDR. +// This model "extends" GatewayChangeRequestUpdatesItem +type GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate struct { + // BGP customer edge router CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on customer edge + // router for the DL 2.0 gateway. + // + // Customer edge IP and IBM IP should be in the same network. Updating customer edge router CIDR should be accompanied + // with IBM CIDR in the request. Update customer edge router IP to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the + // value must reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", + // "169.254.0.0/16" or an owned public CIDR. bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask + // values. + BgpCerCidr *string `json:"bgp_cer_cidr,omitempty"` + + // BGP IBM CIDR is the new CIDR (Classless Inter-Domain Routing) value to be updated on IBM edge router for the DL 2.0 + // gateway. + // + // IBM IP and customer edge IP should be in the same network. Updating IBM CIDR should be accompanied with customer + // edge router CIDR in the request. Update IBM CIDR to a valid bgp_cer_cidr and bgp_ibm_cidr CIDR, the value must + // reside in one of "10.254.0.0/16", "172.16.0.0/12", "192.168.0.0/16", "169.254.0.0/16" or an owned public CIDR. + // bgp_cer_cidr and bgp_ibm_cidr must have matching network and subnet mask values. + BgpIbmCidr *string `json:"bgp_ibm_cidr,omitempty"` +} + +func (*GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate) isaGatewayChangeRequestUpdatesItem() bool { + return true +} + +// UnmarshalGatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate unmarshals an instance of GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate from the specified map of raw messages. +func UnmarshalGatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayChangeRequestUpdatesItemGatewayClientBGPIPUpdate) + err = core.UnmarshalPrimitive(m, "bgp_cer_cidr", &obj.BgpCerCidr) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bgp_ibm_cidr", &obj.BgpIbmCidr) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // GatewayChangeRequestUpdatesItemGatewayClientSpeedUpdate : gateway speed change. // This model "extends" GatewayChangeRequestUpdatesItem type GatewayChangeRequestUpdatesItemGatewayClientSpeedUpdate struct { @@ -4341,11 +5105,164 @@ func UnmarshalGatewayChangeRequestGatewayClientGatewayUpdateAttributes(m map[str return } +// GatewayStatusGatewayBFDStatus : Gateway bfd status. +// This model "extends" GatewayStatus +type GatewayStatusGatewayBFDStatus struct { + // Status type. + Type *string `json:"type" validate:"required"` + + // Date and time status was collected. + UpdatedAt *strfmt.DateTime `json:"updated_at" validate:"required"` + + // Status. + Value *string `json:"value" validate:"required"` +} + +// Constants associated with the GatewayStatusGatewayBFDStatus.Type property. +// Status type. +const ( + GatewayStatusGatewayBFDStatus_Type_Bfd = "bfd" +) + +// Constants associated with the GatewayStatusGatewayBFDStatus.Value property. +// Status. +const ( + GatewayStatusGatewayBFDStatus_Value_Down = "down" + GatewayStatusGatewayBFDStatus_Value_Init = "init" + GatewayStatusGatewayBFDStatus_Value_NotAvailable = "not_available" + GatewayStatusGatewayBFDStatus_Value_Up = "up" +) + +func (*GatewayStatusGatewayBFDStatus) isaGatewayStatus() bool { + return true +} + +// UnmarshalGatewayStatusGatewayBFDStatus unmarshals an instance of GatewayStatusGatewayBFDStatus from the specified map of raw messages. +func UnmarshalGatewayStatusGatewayBFDStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayStatusGatewayBFDStatus) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayStatusGatewayBGPStatus : Gateway bgp status. +// This model "extends" GatewayStatus +type GatewayStatusGatewayBGPStatus struct { + // Status type. + Type *string `json:"type" validate:"required"` + + // Date and time status was collected. + UpdatedAt *strfmt.DateTime `json:"updated_at" validate:"required"` + + // Status. + Value *string `json:"value" validate:"required"` +} + +// Constants associated with the GatewayStatusGatewayBGPStatus.Type property. +// Status type. +const ( + GatewayStatusGatewayBGPStatus_Type_Bgp = "bgp" +) + +// Constants associated with the GatewayStatusGatewayBGPStatus.Value property. +// Status. +const ( + GatewayStatusGatewayBGPStatus_Value_Active = "active" + GatewayStatusGatewayBGPStatus_Value_Connect = "connect" + GatewayStatusGatewayBGPStatus_Value_Established = "established" + GatewayStatusGatewayBGPStatus_Value_Idle = "idle" +) + +func (*GatewayStatusGatewayBGPStatus) isaGatewayStatus() bool { + return true +} + +// UnmarshalGatewayStatusGatewayBGPStatus unmarshals an instance of GatewayStatusGatewayBGPStatus from the specified map of raw messages. +func UnmarshalGatewayStatusGatewayBGPStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayStatusGatewayBGPStatus) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GatewayStatusGatewayLinkStatus : Gateway link status. Only available for dedicated gateways. +// This model "extends" GatewayStatus +type GatewayStatusGatewayLinkStatus struct { + // Status type. + Type *string `json:"type" validate:"required"` + + // Date and time status was collected. + UpdatedAt *strfmt.DateTime `json:"updated_at" validate:"required"` + + // Status. + Value *string `json:"value" validate:"required"` +} + +// Constants associated with the GatewayStatusGatewayLinkStatus.Type property. +// Status type. +const ( + GatewayStatusGatewayLinkStatus_Type_Link = "link" +) + +// Constants associated with the GatewayStatusGatewayLinkStatus.Value property. +// Status. +const ( + GatewayStatusGatewayLinkStatus_Value_Down = "down" + GatewayStatusGatewayLinkStatus_Value_Up = "up" +) + +func (*GatewayStatusGatewayLinkStatus) isaGatewayStatus() bool { + return true +} + +// UnmarshalGatewayStatusGatewayLinkStatus unmarshals an instance of GatewayStatusGatewayLinkStatus from the specified map of raw messages. +func UnmarshalGatewayStatusGatewayLinkStatus(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(GatewayStatusGatewayLinkStatus) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // GatewayTemplateGatewayTypeConnectTemplate : Gateway fields specific to type=connect gateway create. // This model "extends" GatewayTemplate type GatewayTemplateGatewayTypeConnectTemplate struct { AuthenticationKey *GatewayTemplateAuthenticationKey `json:"authentication_key,omitempty"` + BfdConfig *GatewayBfdConfigTemplate `json:"bfd_config,omitempty"` + // BGP ASN. BgpAsn *int64 `json:"bgp_asn" validate:"required"` @@ -4392,6 +5309,9 @@ type GatewayTemplateGatewayTypeConnectTemplate struct { // The unique user-defined name for this gateway. Name *string `json:"name" validate:"required"` + // Gateway patch panel complete notification from implementation team. + PatchPanelCompletionNotice *string `json:"patch_panel_completion_notice,omitempty"` + ResourceGroup *ResourceGroupIdentity `json:"resource_group,omitempty"` // Gateway speed in megabits per second. @@ -4446,6 +5366,10 @@ func UnmarshalGatewayTemplateGatewayTypeConnectTemplate(m map[string]json.RawMes if err != nil { return } + err = core.UnmarshalModel(m, "bfd_config", &obj.BfdConfig, UnmarshalGatewayBfdConfigTemplate) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) if err != nil { return @@ -4478,6 +5402,10 @@ func UnmarshalGatewayTemplateGatewayTypeConnectTemplate(m map[string]json.RawMes if err != nil { return } + err = core.UnmarshalPrimitive(m, "patch_panel_completion_notice", &obj.PatchPanelCompletionNotice) + if err != nil { + return + } err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) if err != nil { return @@ -4503,6 +5431,8 @@ func UnmarshalGatewayTemplateGatewayTypeConnectTemplate(m map[string]json.RawMes type GatewayTemplateGatewayTypeDedicatedTemplate struct { AuthenticationKey *GatewayTemplateAuthenticationKey `json:"authentication_key,omitempty"` + BfdConfig *GatewayBfdConfigTemplate `json:"bfd_config,omitempty"` + // BGP ASN. BgpAsn *int64 `json:"bgp_asn" validate:"required"` @@ -4549,6 +5479,9 @@ type GatewayTemplateGatewayTypeDedicatedTemplate struct { // The unique user-defined name for this gateway. Name *string `json:"name" validate:"required"` + // Gateway patch panel complete notification from implementation team. + PatchPanelCompletionNotice *string `json:"patch_panel_completion_notice,omitempty"` + ResourceGroup *ResourceGroupIdentity `json:"resource_group,omitempty"` // Gateway speed in megabits per second. @@ -4618,6 +5551,10 @@ func UnmarshalGatewayTemplateGatewayTypeDedicatedTemplate(m map[string]json.RawM if err != nil { return } + err = core.UnmarshalModel(m, "bfd_config", &obj.BfdConfig, UnmarshalGatewayBfdConfigTemplate) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "bgp_asn", &obj.BgpAsn) if err != nil { return @@ -4650,6 +5587,10 @@ func UnmarshalGatewayTemplateGatewayTypeDedicatedTemplate(m map[string]json.RawM if err != nil { return } + err = core.UnmarshalPrimitive(m, "patch_panel_completion_notice", &obj.PatchPanelCompletionNotice) + if err != nil { + return + } err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) if err != nil { return diff --git a/directlinkv1/direct_link_v1_integration_test.go b/directlinkv1/direct_link_v1_integration_test.go index 1dfd6e1..cd49bfe 100644 --- a/directlinkv1/direct_link_v1_integration_test.go +++ b/directlinkv1/direct_link_v1_integration_test.go @@ -38,7 +38,6 @@ import ( var configLoaded = false func shouldSkipTest() { - Skip("Skipping test...") if !configLoaded { Skip("External configuration is not available, skipping...") } @@ -1593,4 +1592,216 @@ var _ = Describe(`DirectLinkV1`, func() { }) }) }) + + Describe("BGP IP Update", func() { + timestamp := time.Now().Unix() + gatewayName := "GO-INT-BGP-IP-SDK-" + strconv.FormatInt(timestamp, 10) + bgpAsn := int64(64999) + crossConnectRouter := "LAB-xcr01.dal09" + global := true + locationName := os.Getenv("LOCATION_NAME") + speedMbps := int64(1000) + metered := false + carrierName := "carrier1" + customerName := "customer1" + gatewayType := "dedicated" + + Context("Create a Gateway", func() { + It("should successfully create a gateway", func() { + shouldSkipTest() + + gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) + gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) + gatewayTemplateModel.Global = core.BoolPtr(true) + gatewayTemplateModel.Metered = core.BoolPtr(false) + gatewayTemplateModel.Name = core.StringPtr(gatewayName) + gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) + gatewayTemplateModel.Type = core.StringPtr(gatewayType) + gatewayTemplateModel.CarrierName = core.StringPtr(carrierName) + gatewayTemplateModel.CrossConnectRouter = core.StringPtr(crossConnectRouter) + gatewayTemplateModel.CustomerName = core.StringPtr(customerName) + gatewayTemplateModel.LocationName = core.StringPtr(locationName) + + createGatewayOptions := service.NewCreateGatewayOptions(gatewayTemplateModel) + + result, resp, err := service.CreateGateway(createGatewayOptions) + + Expect(err).To(BeNil()) + Expect(resp.StatusCode).To(Equal(201)) + + os.Setenv("GATEWAY_ID", *result.ID) + os.Setenv("BGP_IP_CER", *result.BgpCerCidr) + os.Setenv("BGP_IP_IBM", *result.BgpIbmCidr) + + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.BgpAsn).To(Equal(bgpAsn)) + Expect(*result.Global).To(Equal(global)) + Expect(*result.Metered).To(Equal(metered)) + Expect(*result.SpeedMbps).To(Equal(speedMbps)) + Expect(*result.Type).To(Equal(gatewayType)) + Expect(*result.CrossConnectRouter).To(Equal(crossConnectRouter)) + Expect(*result.LocationName).To(Equal(locationName)) + Expect(*result.LocationDisplayName).NotTo(Equal("")) + Expect(*result.BgpCerCidr).NotTo(BeEmpty()) + Expect(*result.BgpIbmCidr).NotTo(Equal("")) + Expect(*result.BgpIbmAsn).NotTo(Equal("")) + Expect(*result.BgpStatus).To(Equal("idle")) + Expect(*result.CreatedAt).NotTo(Equal("")) + Expect(*result.Crn).To(HavePrefix("crn:v1")) + Expect(*result.LinkStatus).To(Equal("down")) + Expect(*result.OperationalStatus).To(Equal("awaiting_loa")) + Expect(*result.ResourceGroup.ID).NotTo(Equal("")) + + }) + }) + + Context("Update the BGP ASN for the gateway", func() { + It("should successfully update the bgp asn", func() { + shouldSkipTest() + gatewayId := os.Getenv("GATEWAY_ID") + + bgpAsn := int64(63999) + updateGatewayOptions := service.NewUpdateGatewayOptions(gatewayId).SetBgpAsn(bgpAsn) + res, resp, err := service.UpdateGateway(updateGatewayOptions) + Expect(err).To(BeNil()) + Expect(resp.StatusCode).To(Equal(200)) + + Expect(*res.ID).To(Equal(gatewayId)) + Expect(*res.BgpAsn).To(Equal(bgpAsn)) + Expect(*res.Name).To(Equal(gatewayName)) + }) + }) + + Context("Update the BGP IP for the gateway", func() { + It("should either successfully update the BGP IP CER and IBM CIDR", func() { + shouldSkipTest() + gatewayId := os.Getenv("GATEWAY_ID") + updateGatewayOptions := service.NewUpdateGatewayOptions(gatewayId).SetBgpCerCidr("172.17.252.2/29").SetBgpIbmCidr("172.17.252.1/29") + res, resp, err := service.UpdateGateway(updateGatewayOptions) + if err != nil { + Expect(err.Error()).To(Equal("Please make sure localIP and remoteIP are not in use")) + } else { + Expect(err).To(BeNil()) + Expect(resp.StatusCode).To(Equal(200)) + + Expect(*res.ID).To(Equal(gatewayId)) + Expect(*res.Name).To(Equal(gatewayName)) + } + + }) + }) + + Context("Delete a gateway", func() { + It("Successfully deletes a gateway", func() { + shouldSkipTest() + + gatewayId := os.Getenv("GATEWAY_ID") + deteleGatewayOptions := service.NewDeleteGatewayOptions(gatewayId) + + detailedResponse, err := service.DeleteGateway(deteleGatewayOptions) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(204)) + }) + }) + }) + + Describe("BFD Config", func() { + timestamp := time.Now().Unix() + gatewayName := "GO-INT-BFD-SDK-" + strconv.FormatInt(timestamp, 10) + bgpAsn := int64(64999) + crossConnectRouter := "LAB-xcr01.dal09" + locationName := os.Getenv("LOCATION_NAME") + speedMbps := int64(1000) + carrierName := "carrier1" + customerName := "customer1" + gatewayType := "dedicated" + bfdInterval := int64(1000) + bfdMultiplier := int64(10) + + Context("Create a Gateway", func() { + It("should successfully create a gateway", func() { + shouldSkipTest() + + // Create a template for BFD Config + bfdTemplate := new(directlinkv1.GatewayBfdConfigTemplate) + bfdTemplate.Interval = &bfdInterval + bfdTemplate.Multiplier = &bfdMultiplier + + // Create a template for Gateway model + gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) + gatewayTemplateModel.BgpAsn = core.Int64Ptr(bgpAsn) + gatewayTemplateModel.Global = core.BoolPtr(true) + gatewayTemplateModel.Metered = core.BoolPtr(false) + gatewayTemplateModel.Name = core.StringPtr(gatewayName) + gatewayTemplateModel.SpeedMbps = core.Int64Ptr(speedMbps) + gatewayTemplateModel.Type = core.StringPtr(gatewayType) + gatewayTemplateModel.CarrierName = core.StringPtr(carrierName) + gatewayTemplateModel.CrossConnectRouter = core.StringPtr(crossConnectRouter) + gatewayTemplateModel.CustomerName = core.StringPtr(customerName) + gatewayTemplateModel.LocationName = core.StringPtr(locationName) + gatewayTemplateModel.BfdConfig = bfdTemplate + + createGatewayOptions := service.NewCreateGatewayOptions(gatewayTemplateModel) + + result, resp, err := service.CreateGateway(createGatewayOptions) + + Expect(err).To(BeNil()) + Expect(resp.StatusCode).To(Equal(201)) + + os.Setenv("GATEWAY_ID", *result.ID) + + Expect(*result.Name).To(Equal(gatewayName)) + Expect(*result.Type).To(Equal(gatewayType)) + Expect(*result.CrossConnectRouter).To(Equal(crossConnectRouter)) + Expect(*result.LocationName).To(Equal(locationName)) + Expect(*result.LocationDisplayName).NotTo(Equal("")) + Expect(*result.BgpStatus).To(Equal("idle")) + Expect(*result.OperationalStatus).To(Equal("awaiting_loa")) + Expect(result.BfdConfig).NotTo(BeNil()) + Expect(result.BfdConfig.BfdStatus).NotTo(BeNil()) + Expect(*result.BfdConfig.Interval).To(Equal(bfdInterval)) + Expect(*result.BfdConfig.Multiplier).To(Equal(bfdMultiplier)) + }) + }) + + Context("Update the BFD Config for the gateway", func() { + It("should successfully update the bfd config", func() { + shouldSkipTest() + gatewayId := os.Getenv("GATEWAY_ID") + + updatedBfdInterval := int64(400) + updatedBfdMultiplier := int64(200) + + // Create a template for BFD Config + bfdPatchTemplate := new(directlinkv1.GatewayBfdPatchTemplate) + bfdPatchTemplate.Interval = &updatedBfdInterval + bfdPatchTemplate.Multiplier = &updatedBfdMultiplier + + updateGatewayOptions := service.NewUpdateGatewayOptions(gatewayId).SetBfdConfig(bfdPatchTemplate) + res, resp, err := service.UpdateGateway(updateGatewayOptions) + Expect(err).To(BeNil()) + Expect(resp.StatusCode).To(Equal(200)) + + Expect(*res.ID).To(Equal(gatewayId)) + Expect(*res.Name).To(Equal(gatewayName)) + Expect(res.BfdConfig).NotTo(BeNil()) + Expect(res.BfdConfig.BfdStatus).NotTo(BeNil()) + Expect(*res.BfdConfig.Interval).To(Equal(updatedBfdInterval)) + Expect(*res.BfdConfig.Multiplier).To(Equal(updatedBfdMultiplier)) + }) + }) + + Context("Delete a gateway", func() { + It("Successfully deletes a gateway", func() { + shouldSkipTest() + + gatewayId := os.Getenv("GATEWAY_ID") + deteleGatewayOptions := service.NewDeleteGatewayOptions(gatewayId) + + detailedResponse, err := service.DeleteGateway(deteleGatewayOptions) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(204)) + }) + }) + }) }) diff --git a/directlinkv1/direct_link_v1_test.go b/directlinkv1/direct_link_v1_test.go index a97b417..59e5078 100644 --- a/directlinkv1/direct_link_v1_test.go +++ b/directlinkv1/direct_link_v1_test.go @@ -245,7 +245,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}`) + fmt.Fprintf(res, "%s", `{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}`) })) }) It(`Invoke ListGateways successfully with retries`, func() { @@ -300,7 +300,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}`) + fmt.Fprintf(res, "%s", `{"gateways": [{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}]}`) })) }) It(`Invoke ListGateways successfully`, func() { @@ -419,6 +419,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel := new(directlinkv1.GatewayTemplateAuthenticationKey) gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -441,6 +446,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Construct an instance of the GatewayTemplateGatewayTypeDedicatedTemplate model gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -449,6 +455,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -515,7 +522,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke CreateGateway successfully with retries`, func() { @@ -532,6 +539,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel := new(directlinkv1.GatewayTemplateAuthenticationKey) gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -554,6 +566,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Construct an instance of the GatewayTemplateGatewayTypeDedicatedTemplate model gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -562,6 +575,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -630,7 +644,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke CreateGateway successfully`, func() { @@ -652,6 +666,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel := new(directlinkv1.GatewayTemplateAuthenticationKey) gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -674,6 +693,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Construct an instance of the GatewayTemplateGatewayTypeDedicatedTemplate model gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -682,6 +702,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -716,6 +737,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel := new(directlinkv1.GatewayTemplateAuthenticationKey) gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -738,6 +764,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Construct an instance of the GatewayTemplateGatewayTypeDedicatedTemplate model gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -746,6 +773,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -801,6 +829,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel := new(directlinkv1.GatewayTemplateAuthenticationKey) gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -823,6 +856,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Construct an instance of the GatewayTemplateGatewayTypeDedicatedTemplate model gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -831,6 +865,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -997,7 +1032,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke GetGateway successfully with retries`, func() { @@ -1053,7 +1088,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke GetGateway successfully`, func() { @@ -1182,6 +1217,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel := new(directlinkv1.GatewayPatchTemplateAuthenticationKey) gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) gatewayMacsecConfigPatchTemplateFallbackCakModel.Crn = core.StringPtr("crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222") @@ -1201,6 +1241,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := new(directlinkv1.UpdateGatewayOptions) updateGatewayOptionsModel.ID = core.StringPtr("testString") updateGatewayOptionsModel.AuthenticationKey = gatewayPatchTemplateAuthenticationKeyModel + updateGatewayOptionsModel.BfdConfig = gatewayBfdPatchTemplateModel + updateGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateGatewayOptionsModel.ConnectionMode = core.StringPtr("transit") updateGatewayOptionsModel.Global = core.BoolPtr(true) updateGatewayOptionsModel.LoaRejectReason = core.StringPtr("The port mentioned was incorrect") @@ -1208,6 +1252,7 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.Metered = core.BoolPtr(false) updateGatewayOptionsModel.Name = core.StringPtr("testGateway") updateGatewayOptionsModel.OperationalStatus = core.StringPtr("loa_accepted") + updateGatewayOptionsModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") updateGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response @@ -1263,7 +1308,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke UpdateGateway successfully with retries`, func() { @@ -1280,6 +1325,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel := new(directlinkv1.GatewayPatchTemplateAuthenticationKey) gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) gatewayMacsecConfigPatchTemplateFallbackCakModel.Crn = core.StringPtr("crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222") @@ -1299,6 +1349,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := new(directlinkv1.UpdateGatewayOptions) updateGatewayOptionsModel.ID = core.StringPtr("testString") updateGatewayOptionsModel.AuthenticationKey = gatewayPatchTemplateAuthenticationKeyModel + updateGatewayOptionsModel.BfdConfig = gatewayBfdPatchTemplateModel + updateGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateGatewayOptionsModel.ConnectionMode = core.StringPtr("transit") updateGatewayOptionsModel.Global = core.BoolPtr(true) updateGatewayOptionsModel.LoaRejectReason = core.StringPtr("The port mentioned was incorrect") @@ -1306,6 +1360,7 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.Metered = core.BoolPtr(false) updateGatewayOptionsModel.Name = core.StringPtr("testGateway") updateGatewayOptionsModel.OperationalStatus = core.StringPtr("loa_accepted") + updateGatewayOptionsModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") updateGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -1363,7 +1418,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke UpdateGateway successfully`, func() { @@ -1385,6 +1440,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel := new(directlinkv1.GatewayPatchTemplateAuthenticationKey) gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) gatewayMacsecConfigPatchTemplateFallbackCakModel.Crn = core.StringPtr("crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222") @@ -1404,6 +1464,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := new(directlinkv1.UpdateGatewayOptions) updateGatewayOptionsModel.ID = core.StringPtr("testString") updateGatewayOptionsModel.AuthenticationKey = gatewayPatchTemplateAuthenticationKeyModel + updateGatewayOptionsModel.BfdConfig = gatewayBfdPatchTemplateModel + updateGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateGatewayOptionsModel.ConnectionMode = core.StringPtr("transit") updateGatewayOptionsModel.Global = core.BoolPtr(true) updateGatewayOptionsModel.LoaRejectReason = core.StringPtr("The port mentioned was incorrect") @@ -1411,6 +1475,7 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.Metered = core.BoolPtr(false) updateGatewayOptionsModel.Name = core.StringPtr("testGateway") updateGatewayOptionsModel.OperationalStatus = core.StringPtr("loa_accepted") + updateGatewayOptionsModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") updateGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -1434,6 +1499,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel := new(directlinkv1.GatewayPatchTemplateAuthenticationKey) gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) gatewayMacsecConfigPatchTemplateFallbackCakModel.Crn = core.StringPtr("crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222") @@ -1453,6 +1523,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := new(directlinkv1.UpdateGatewayOptions) updateGatewayOptionsModel.ID = core.StringPtr("testString") updateGatewayOptionsModel.AuthenticationKey = gatewayPatchTemplateAuthenticationKeyModel + updateGatewayOptionsModel.BfdConfig = gatewayBfdPatchTemplateModel + updateGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateGatewayOptionsModel.ConnectionMode = core.StringPtr("transit") updateGatewayOptionsModel.Global = core.BoolPtr(true) updateGatewayOptionsModel.LoaRejectReason = core.StringPtr("The port mentioned was incorrect") @@ -1460,6 +1534,7 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.Metered = core.BoolPtr(false) updateGatewayOptionsModel.Name = core.StringPtr("testGateway") updateGatewayOptionsModel.OperationalStatus = core.StringPtr("loa_accepted") + updateGatewayOptionsModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") updateGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) @@ -1504,6 +1579,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel := new(directlinkv1.GatewayPatchTemplateAuthenticationKey) gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) gatewayMacsecConfigPatchTemplateFallbackCakModel.Crn = core.StringPtr("crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222") @@ -1523,6 +1603,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := new(directlinkv1.UpdateGatewayOptions) updateGatewayOptionsModel.ID = core.StringPtr("testString") updateGatewayOptionsModel.AuthenticationKey = gatewayPatchTemplateAuthenticationKeyModel + updateGatewayOptionsModel.BfdConfig = gatewayBfdPatchTemplateModel + updateGatewayOptionsModel.BgpAsn = core.Int64Ptr(int64(64999)) + updateGatewayOptionsModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") + updateGatewayOptionsModel.BgpIbmCidr = core.StringPtr("169.254.0.9/30") updateGatewayOptionsModel.ConnectionMode = core.StringPtr("transit") updateGatewayOptionsModel.Global = core.BoolPtr(true) updateGatewayOptionsModel.LoaRejectReason = core.StringPtr("The port mentioned was incorrect") @@ -1530,6 +1614,7 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.Metered = core.BoolPtr(false) updateGatewayOptionsModel.Name = core.StringPtr("testGateway") updateGatewayOptionsModel.OperationalStatus = core.StringPtr("loa_accepted") + updateGatewayOptionsModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") updateGatewayOptionsModel.SpeedMbps = core.Int64Ptr(int64(1000)) updateGatewayOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -1576,6 +1661,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel := new(directlinkv1.GatewayActionTemplateAuthenticationKey) gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -1589,6 +1679,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.ID = core.StringPtr("testString") createGatewayActionOptionsModel.Action = core.StringPtr("create_gateway_approve") createGatewayActionOptionsModel.AuthenticationKey = gatewayActionTemplateAuthenticationKeyModel + createGatewayActionOptionsModel.BfdConfig = gatewayBfdConfigActionTemplateModel createGatewayActionOptionsModel.ConnectionMode = core.StringPtr("transit") createGatewayActionOptionsModel.Global = core.BoolPtr(true) createGatewayActionOptionsModel.Metered = core.BoolPtr(false) @@ -1648,7 +1739,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke CreateGatewayAction successfully with retries`, func() { @@ -1665,6 +1756,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel := new(directlinkv1.GatewayActionTemplateAuthenticationKey) gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -1678,6 +1774,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.ID = core.StringPtr("testString") createGatewayActionOptionsModel.Action = core.StringPtr("create_gateway_approve") createGatewayActionOptionsModel.AuthenticationKey = gatewayActionTemplateAuthenticationKeyModel + createGatewayActionOptionsModel.BfdConfig = gatewayBfdConfigActionTemplateModel createGatewayActionOptionsModel.ConnectionMode = core.StringPtr("transit") createGatewayActionOptionsModel.Global = core.BoolPtr(true) createGatewayActionOptionsModel.Metered = core.BoolPtr(false) @@ -1739,7 +1836,7 @@ var _ = Describe(`DirectLinkV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) + fmt.Fprintf(res, "%s", `{"authentication_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"}, "bfd_config": {"bfd_status": "active", "bfd_status_updated_at": "2020-08-20T06:58:41.909Z", "interval": 2000, "multiplier": 10}, "bgp_asn": 64999, "bgp_base_cidr": "BgpBaseCidr", "bgp_cer_cidr": "10.254.30.78/30", "bgp_ibm_asn": 13884, "bgp_ibm_cidr": "10.254.30.77/30", "bgp_status": "active", "bgp_status_updated_at": "2020-08-20T06:58:41.909Z", "carrier_name": "myCarrierName", "change_request": {"type": "create_gateway"}, "completion_notice_reject_reason": "The completion notice file was blank", "connection_mode": "transit", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:directlink:dal03:a/4111d05f36894e3cb9b46a43556d9000::dedicated:ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "cross_connect_router": "xcr01.dal03", "customer_name": "newCustomerName", "global": true, "id": "ef4dcb1a-fee4-41c7-9e11-9cd99e65c1f4", "link_status": "up", "link_status_updated_at": "2020-08-20T06:58:41.909Z", "location_display_name": "Dallas 03", "location_name": "dal03", "macsec_config": {"active": true, "active_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "cipher_suite": "gcm_aes_xpn_256", "confidentiality_offset": 0, "cryptographic_algorithm": "aes_256_cmac", "fallback_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "key_server_priority": 255, "primary_cak": {"crn": "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222", "status": "Status"}, "sak_expiry_time": 3600, "security_policy": "must_secure", "status": "secured", "window_size": 64}, "metered": false, "name": "myGateway", "operational_status": "awaiting_completion_notice", "patch_panel_completion_notice": "patch panel configuration details", "port": {"id": "54321b1a-fee4-41c7-9e11-9cd99e000aaa"}, "provider_api_managed": false, "resource_group": {"id": "56969d6043e9465c883cb9f7363e78e8"}, "speed_mbps": 1000, "type": "dedicated", "vlan": 10}`) })) }) It(`Invoke CreateGatewayAction successfully`, func() { @@ -1761,6 +1858,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel := new(directlinkv1.GatewayActionTemplateAuthenticationKey) gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -1774,6 +1876,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.ID = core.StringPtr("testString") createGatewayActionOptionsModel.Action = core.StringPtr("create_gateway_approve") createGatewayActionOptionsModel.AuthenticationKey = gatewayActionTemplateAuthenticationKeyModel + createGatewayActionOptionsModel.BfdConfig = gatewayBfdConfigActionTemplateModel createGatewayActionOptionsModel.ConnectionMode = core.StringPtr("transit") createGatewayActionOptionsModel.Global = core.BoolPtr(true) createGatewayActionOptionsModel.Metered = core.BoolPtr(false) @@ -1801,6 +1904,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel := new(directlinkv1.GatewayActionTemplateAuthenticationKey) gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -1814,6 +1922,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.ID = core.StringPtr("testString") createGatewayActionOptionsModel.Action = core.StringPtr("create_gateway_approve") createGatewayActionOptionsModel.AuthenticationKey = gatewayActionTemplateAuthenticationKeyModel + createGatewayActionOptionsModel.BfdConfig = gatewayBfdConfigActionTemplateModel createGatewayActionOptionsModel.ConnectionMode = core.StringPtr("transit") createGatewayActionOptionsModel.Global = core.BoolPtr(true) createGatewayActionOptionsModel.Metered = core.BoolPtr(false) @@ -1862,6 +1971,11 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel := new(directlinkv1.GatewayActionTemplateAuthenticationKey) gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) resourceGroupIdentityModel.ID = core.StringPtr("56969d6043e9465c883cb9f7363e78e8") @@ -1875,6 +1989,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.ID = core.StringPtr("testString") createGatewayActionOptionsModel.Action = core.StringPtr("create_gateway_approve") createGatewayActionOptionsModel.AuthenticationKey = gatewayActionTemplateAuthenticationKeyModel + createGatewayActionOptionsModel.BfdConfig = gatewayBfdConfigActionTemplateModel createGatewayActionOptionsModel.ConnectionMode = core.StringPtr("transit") createGatewayActionOptionsModel.Global = core.BoolPtr(true) createGatewayActionOptionsModel.Metered = core.BoolPtr(false) @@ -2573,6 +2688,236 @@ var _ = Describe(`DirectLinkV1`, func() { }) }) }) + Describe(`GetGatewayStatus(getGatewayStatusOptions *GetGatewayStatusOptions) - Operation response error`, func() { + version := "testString" + getGatewayStatusPath := "/gateways/testString/status" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getGatewayStatusPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"bgp"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetGatewayStatus with error: Operation response processing error`, func() { + directLinkService, serviceErr := directlinkv1.NewDirectLinkV1(&directlinkv1.DirectLinkV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkService).ToNot(BeNil()) + + // Construct an instance of the GetGatewayStatusOptions model + getGatewayStatusOptionsModel := new(directlinkv1.GetGatewayStatusOptions) + getGatewayStatusOptionsModel.ID = core.StringPtr("testString") + getGatewayStatusOptionsModel.Type = core.StringPtr("bgp") + getGatewayStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + directLinkService.EnableRetries(0, 0) + result, response, operationErr = directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetGatewayStatus(getGatewayStatusOptions *GetGatewayStatusOptions)`, func() { + version := "testString" + getGatewayStatusPath := "/gateways/testString/status" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getGatewayStatusPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"bgp"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"status": [{"type": "bgp", "updated_at": "2020-08-20T06:58:41.909Z", "value": "active"}]}`) + })) + }) + It(`Invoke GetGatewayStatus successfully with retries`, func() { + directLinkService, serviceErr := directlinkv1.NewDirectLinkV1(&directlinkv1.DirectLinkV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkService).ToNot(BeNil()) + directLinkService.EnableRetries(0, 0) + + // Construct an instance of the GetGatewayStatusOptions model + getGatewayStatusOptionsModel := new(directlinkv1.GetGatewayStatusOptions) + getGatewayStatusOptionsModel.ID = core.StringPtr("testString") + getGatewayStatusOptionsModel.Type = core.StringPtr("bgp") + getGatewayStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := directLinkService.GetGatewayStatusWithContext(ctx, getGatewayStatusOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + directLinkService.DisableRetries() + result, response, operationErr := directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = directLinkService.GetGatewayStatusWithContext(ctx, getGatewayStatusOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getGatewayStatusPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["type"]).To(Equal([]string{"bgp"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"status": [{"type": "bgp", "updated_at": "2020-08-20T06:58:41.909Z", "value": "active"}]}`) + })) + }) + It(`Invoke GetGatewayStatus successfully`, func() { + directLinkService, serviceErr := directlinkv1.NewDirectLinkV1(&directlinkv1.DirectLinkV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := directLinkService.GetGatewayStatus(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetGatewayStatusOptions model + getGatewayStatusOptionsModel := new(directlinkv1.GetGatewayStatusOptions) + getGatewayStatusOptionsModel.ID = core.StringPtr("testString") + getGatewayStatusOptionsModel.Type = core.StringPtr("bgp") + getGatewayStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetGatewayStatus with error: Operation validation and request error`, func() { + directLinkService, serviceErr := directlinkv1.NewDirectLinkV1(&directlinkv1.DirectLinkV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkService).ToNot(BeNil()) + + // Construct an instance of the GetGatewayStatusOptions model + getGatewayStatusOptionsModel := new(directlinkv1.GetGatewayStatusOptions) + getGatewayStatusOptionsModel.ID = core.StringPtr("testString") + getGatewayStatusOptionsModel.Type = core.StringPtr("bgp") + getGatewayStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := directLinkService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetGatewayStatusOptions model with no property values + getGatewayStatusOptionsModelNew := new(directlinkv1.GetGatewayStatusOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = directLinkService.GetGatewayStatus(getGatewayStatusOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetGatewayStatus successfully`, func() { + directLinkService, serviceErr := directlinkv1.NewDirectLinkV1(&directlinkv1.DirectLinkV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(directLinkService).ToNot(BeNil()) + + // Construct an instance of the GetGatewayStatusOptions model + getGatewayStatusOptionsModel := new(directlinkv1.GetGatewayStatusOptions) + getGatewayStatusOptionsModel.ID = core.StringPtr("testString") + getGatewayStatusOptionsModel.Type = core.StringPtr("bgp") + getGatewayStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := directLinkService.GetGatewayStatus(getGatewayStatusOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`ListOfferingTypeLocations(listOfferingTypeLocationsOptions *ListOfferingTypeLocationsOptions) - Operation response error`, func() { version := "testString" listOfferingTypeLocationsPath := "/offering_types/dedicated/locations" @@ -4776,6 +5121,14 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayActionTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") Expect(gatewayActionTemplateAuthenticationKeyModel.Crn).To(Equal(core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"))) + // Construct an instance of the GatewayBfdConfigActionTemplate model + gatewayBfdConfigActionTemplateModel := new(directlinkv1.GatewayBfdConfigActionTemplate) + Expect(gatewayBfdConfigActionTemplateModel).ToNot(BeNil()) + gatewayBfdConfigActionTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigActionTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + Expect(gatewayBfdConfigActionTemplateModel.Interval).To(Equal(core.Int64Ptr(int64(2000)))) + Expect(gatewayBfdConfigActionTemplateModel.Multiplier).To(Equal(core.Int64Ptr(int64(10)))) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) Expect(resourceGroupIdentityModel).ToNot(BeNil()) @@ -4795,6 +5148,7 @@ var _ = Describe(`DirectLinkV1`, func() { createGatewayActionOptionsModel.SetID("testString") createGatewayActionOptionsModel.SetAction("create_gateway_approve") createGatewayActionOptionsModel.SetAuthenticationKey(gatewayActionTemplateAuthenticationKeyModel) + createGatewayActionOptionsModel.SetBfdConfig(gatewayBfdConfigActionTemplateModel) createGatewayActionOptionsModel.SetConnectionMode("transit") createGatewayActionOptionsModel.SetGlobal(true) createGatewayActionOptionsModel.SetMetered(false) @@ -4805,6 +5159,7 @@ var _ = Describe(`DirectLinkV1`, func() { Expect(createGatewayActionOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(createGatewayActionOptionsModel.Action).To(Equal(core.StringPtr("create_gateway_approve"))) Expect(createGatewayActionOptionsModel.AuthenticationKey).To(Equal(gatewayActionTemplateAuthenticationKeyModel)) + Expect(createGatewayActionOptionsModel.BfdConfig).To(Equal(gatewayBfdConfigActionTemplateModel)) Expect(createGatewayActionOptionsModel.ConnectionMode).To(Equal(core.StringPtr("transit"))) Expect(createGatewayActionOptionsModel.Global).To(Equal(core.BoolPtr(true))) Expect(createGatewayActionOptionsModel.Metered).To(Equal(core.BoolPtr(false))) @@ -4833,6 +5188,14 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") Expect(gatewayTemplateAuthenticationKeyModel.Crn).To(Equal(core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"))) + // Construct an instance of the GatewayBfdConfigTemplate model + gatewayBfdConfigTemplateModel := new(directlinkv1.GatewayBfdConfigTemplate) + Expect(gatewayBfdConfigTemplateModel).ToNot(BeNil()) + gatewayBfdConfigTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdConfigTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + Expect(gatewayBfdConfigTemplateModel.Interval).To(Equal(core.Int64Ptr(int64(2000)))) + Expect(gatewayBfdConfigTemplateModel.Multiplier).To(Equal(core.Int64Ptr(int64(10)))) + // Construct an instance of the ResourceGroupIdentity model resourceGroupIdentityModel := new(directlinkv1.ResourceGroupIdentity) Expect(resourceGroupIdentityModel).ToNot(BeNil()) @@ -4867,6 +5230,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel := new(directlinkv1.GatewayTemplateGatewayTypeDedicatedTemplate) Expect(gatewayTemplateModel).ToNot(BeNil()) gatewayTemplateModel.AuthenticationKey = gatewayTemplateAuthenticationKeyModel + gatewayTemplateModel.BfdConfig = gatewayBfdConfigTemplateModel gatewayTemplateModel.BgpAsn = core.Int64Ptr(int64(64999)) gatewayTemplateModel.BgpBaseCidr = core.StringPtr("testString") gatewayTemplateModel.BgpCerCidr = core.StringPtr("169.254.0.10/30") @@ -4875,6 +5239,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.Global = core.BoolPtr(true) gatewayTemplateModel.Metered = core.BoolPtr(false) gatewayTemplateModel.Name = core.StringPtr("myGateway") + gatewayTemplateModel.PatchPanelCompletionNotice = core.StringPtr("patch panel configuration details") gatewayTemplateModel.ResourceGroup = resourceGroupIdentityModel gatewayTemplateModel.SpeedMbps = core.Int64Ptr(int64(1000)) gatewayTemplateModel.Type = core.StringPtr("dedicated") @@ -4884,6 +5249,7 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayTemplateModel.LocationName = core.StringPtr("dal03") gatewayTemplateModel.MacsecConfig = gatewayMacsecConfigTemplateModel Expect(gatewayTemplateModel.AuthenticationKey).To(Equal(gatewayTemplateAuthenticationKeyModel)) + Expect(gatewayTemplateModel.BfdConfig).To(Equal(gatewayBfdConfigTemplateModel)) Expect(gatewayTemplateModel.BgpAsn).To(Equal(core.Int64Ptr(int64(64999)))) Expect(gatewayTemplateModel.BgpBaseCidr).To(Equal(core.StringPtr("testString"))) Expect(gatewayTemplateModel.BgpCerCidr).To(Equal(core.StringPtr("169.254.0.10/30"))) @@ -4892,6 +5258,7 @@ var _ = Describe(`DirectLinkV1`, func() { Expect(gatewayTemplateModel.Global).To(Equal(core.BoolPtr(true))) Expect(gatewayTemplateModel.Metered).To(Equal(core.BoolPtr(false))) Expect(gatewayTemplateModel.Name).To(Equal(core.StringPtr("myGateway"))) + Expect(gatewayTemplateModel.PatchPanelCompletionNotice).To(Equal(core.StringPtr("patch panel configuration details"))) Expect(gatewayTemplateModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) Expect(gatewayTemplateModel.SpeedMbps).To(Equal(core.Int64Ptr(int64(1000)))) Expect(gatewayTemplateModel.Type).To(Equal(core.StringPtr("dedicated"))) @@ -4957,6 +5324,18 @@ var _ = Describe(`DirectLinkV1`, func() { Expect(model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewGatewayBfdConfigActionTemplate successfully`, func() { + interval := int64(2000) + model, err := directLinkService.NewGatewayBfdConfigActionTemplate(interval) + Expect(model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewGatewayBfdConfigTemplate successfully`, func() { + interval := int64(2000) + model, err := directLinkService.NewGatewayBfdConfigTemplate(interval) + Expect(model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewGatewayMacsecConfigPatchTemplateFallbackCak successfully`, func() { crn := "crn:v1:bluemix:public:hs-crypto:us-south:a/4111d05f36894e3cb9b46a43556d9000:abc111b8-37aa-4034-9def-f2607c87aaaa:key:bbb222bc-430a-4de9-9aad-84e5bb022222" model, err := directLinkService.NewGatewayMacsecConfigPatchTemplateFallbackCak(crn) @@ -5028,6 +5407,18 @@ var _ = Describe(`DirectLinkV1`, func() { Expect(getGatewayStatisticsOptionsModel.Type).To(Equal(core.StringPtr("macsec_mka"))) Expect(getGatewayStatisticsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetGatewayStatusOptions successfully`, func() { + // Construct an instance of the GetGatewayStatusOptions model + id := "testString" + getGatewayStatusOptionsModel := directLinkService.NewGetGatewayStatusOptions(id) + getGatewayStatusOptionsModel.SetID("testString") + getGatewayStatusOptionsModel.SetType("bgp") + getGatewayStatusOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getGatewayStatusOptionsModel).ToNot(BeNil()) + Expect(getGatewayStatusOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getGatewayStatusOptionsModel.Type).To(Equal(core.StringPtr("bgp"))) + Expect(getGatewayStatusOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetGatewayVirtualConnectionOptions successfully`, func() { // Construct an instance of the GetGatewayVirtualConnectionOptions model gatewayID := "testString" @@ -5147,6 +5538,14 @@ var _ = Describe(`DirectLinkV1`, func() { gatewayPatchTemplateAuthenticationKeyModel.Crn = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c") Expect(gatewayPatchTemplateAuthenticationKeyModel.Crn).To(Equal(core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/766d8d374a484f029d0fca5a40a52a1c:5d343839-07d3-4213-a950-0f71ed45423f:key:7fc1a0ba-4633-48cb-997b-5749787c952c"))) + // Construct an instance of the GatewayBfdPatchTemplate model + gatewayBfdPatchTemplateModel := new(directlinkv1.GatewayBfdPatchTemplate) + Expect(gatewayBfdPatchTemplateModel).ToNot(BeNil()) + gatewayBfdPatchTemplateModel.Interval = core.Int64Ptr(int64(2000)) + gatewayBfdPatchTemplateModel.Multiplier = core.Int64Ptr(int64(10)) + Expect(gatewayBfdPatchTemplateModel.Interval).To(Equal(core.Int64Ptr(int64(2000)))) + Expect(gatewayBfdPatchTemplateModel.Multiplier).To(Equal(core.Int64Ptr(int64(10)))) + // Construct an instance of the GatewayMacsecConfigPatchTemplateFallbackCak model gatewayMacsecConfigPatchTemplateFallbackCakModel := new(directlinkv1.GatewayMacsecConfigPatchTemplateFallbackCak) Expect(gatewayMacsecConfigPatchTemplateFallbackCakModel).ToNot(BeNil()) @@ -5176,6 +5575,10 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel := directLinkService.NewUpdateGatewayOptions(id) updateGatewayOptionsModel.SetID("testString") updateGatewayOptionsModel.SetAuthenticationKey(gatewayPatchTemplateAuthenticationKeyModel) + updateGatewayOptionsModel.SetBfdConfig(gatewayBfdPatchTemplateModel) + updateGatewayOptionsModel.SetBgpAsn(int64(64999)) + updateGatewayOptionsModel.SetBgpCerCidr("169.254.0.10/30") + updateGatewayOptionsModel.SetBgpIbmCidr("169.254.0.9/30") updateGatewayOptionsModel.SetConnectionMode("transit") updateGatewayOptionsModel.SetGlobal(true) updateGatewayOptionsModel.SetLoaRejectReason("The port mentioned was incorrect") @@ -5183,11 +5586,16 @@ var _ = Describe(`DirectLinkV1`, func() { updateGatewayOptionsModel.SetMetered(false) updateGatewayOptionsModel.SetName("testGateway") updateGatewayOptionsModel.SetOperationalStatus("loa_accepted") + updateGatewayOptionsModel.SetPatchPanelCompletionNotice("patch panel configuration details") updateGatewayOptionsModel.SetSpeedMbps(int64(1000)) updateGatewayOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateGatewayOptionsModel).ToNot(BeNil()) Expect(updateGatewayOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateGatewayOptionsModel.AuthenticationKey).To(Equal(gatewayPatchTemplateAuthenticationKeyModel)) + Expect(updateGatewayOptionsModel.BfdConfig).To(Equal(gatewayBfdPatchTemplateModel)) + Expect(updateGatewayOptionsModel.BgpAsn).To(Equal(core.Int64Ptr(int64(64999)))) + Expect(updateGatewayOptionsModel.BgpCerCidr).To(Equal(core.StringPtr("169.254.0.10/30"))) + Expect(updateGatewayOptionsModel.BgpIbmCidr).To(Equal(core.StringPtr("169.254.0.9/30"))) Expect(updateGatewayOptionsModel.ConnectionMode).To(Equal(core.StringPtr("transit"))) Expect(updateGatewayOptionsModel.Global).To(Equal(core.BoolPtr(true))) Expect(updateGatewayOptionsModel.LoaRejectReason).To(Equal(core.StringPtr("The port mentioned was incorrect"))) @@ -5195,6 +5603,7 @@ var _ = Describe(`DirectLinkV1`, func() { Expect(updateGatewayOptionsModel.Metered).To(Equal(core.BoolPtr(false))) Expect(updateGatewayOptionsModel.Name).To(Equal(core.StringPtr("testGateway"))) Expect(updateGatewayOptionsModel.OperationalStatus).To(Equal(core.StringPtr("loa_accepted"))) + Expect(updateGatewayOptionsModel.PatchPanelCompletionNotice).To(Equal(core.StringPtr("patch panel configuration details"))) Expect(updateGatewayOptionsModel.SpeedMbps).To(Equal(core.Int64Ptr(int64(1000)))) Expect(updateGatewayOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) })