Skip to content

Commit

Permalink
SDK generation update
Browse files Browse the repository at this point in the history
  • Loading branch information
luiof committed Apr 4, 2023
1 parent 61c5560 commit 4ff6e02
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 2 deletions.
82 changes: 80 additions & 2 deletions projectv1/project_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (project *ProjectV1) DisableRetries() {
}

// CreateProject : Create a project
// Create a new project and asynchronously setup the tools to manage it. An initial pull request is created on the
// project Git repo. After approving the pull request, the user can deploy the resources that the project configures.
// Create a new project and asynchronously setup the tools to manage it. Add a deployable architecture by customizing
// the configuration. After the changes are validated and approved, deploy the resources that the project configures.
func (project *ProjectV1) CreateProject(createProjectOptions *CreateProjectOptions) (result *Project, response *core.DetailedResponse, err error) {
return project.CreateProjectWithContext(context.Background(), createProjectOptions)
}
Expand Down Expand Up @@ -1622,6 +1622,56 @@ func (project *ProjectV1) ReceivePulsarCatalogEventsWithContext(ctx context.Cont
return
}

// ReceivePulsarEventNotificationEvents : Webhook for event notifications events
// This is a webhook for event notifications events.
func (project *ProjectV1) ReceivePulsarEventNotificationEvents(receivePulsarEventNotificationEventsOptions *ReceivePulsarEventNotificationEventsOptions) (response *core.DetailedResponse, err error) {
return project.ReceivePulsarEventNotificationEventsWithContext(context.Background(), receivePulsarEventNotificationEventsOptions)
}

// ReceivePulsarEventNotificationEventsWithContext is an alternate form of the ReceivePulsarEventNotificationEvents method which supports a Context parameter
func (project *ProjectV1) ReceivePulsarEventNotificationEventsWithContext(ctx context.Context, receivePulsarEventNotificationEventsOptions *ReceivePulsarEventNotificationEventsOptions) (response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(receivePulsarEventNotificationEventsOptions, "receivePulsarEventNotificationEventsOptions cannot be nil")
if err != nil {
return
}
err = core.ValidateStruct(receivePulsarEventNotificationEventsOptions, "receivePulsarEventNotificationEventsOptions")
if err != nil {
return
}

builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = project.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(project.Service.Options.URL, `/v1/pulsar/event_notification_events`, nil)
if err != nil {
return
}

for headerName, headerValue := range receivePulsarEventNotificationEventsOptions.Headers {
builder.AddHeader(headerName, headerValue)
}

sdkHeaders := common.GetSdkHeaders("project", "V1", "ReceivePulsarEventNotificationEvents")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Content-Type", "application/json")

_, err = builder.SetBodyContentJSON(receivePulsarEventNotificationEventsOptions.PulsarEventNotificationEvents)
if err != nil {
return
}

request, err := builder.Build()
if err != nil {
return
}

response, err = project.Service.Request(request, nil)

return
}

// GetHealth : Get service health information
// Get service health information.
func (project *ProjectV1) GetHealth(getHealthOptions *GetHealthOptions) (result *Health, response *core.DetailedResponse, err error) {
Expand Down Expand Up @@ -5643,6 +5693,34 @@ func (options *ReceivePulsarCatalogEventsOptions) SetHeaders(param map[string]st
return options
}

// ReceivePulsarEventNotificationEventsOptions : The ReceivePulsarEventNotificationEvents options.
type ReceivePulsarEventNotificationEventsOptions struct {
// A pulsar event.
PulsarEventNotificationEvents []PulsarEventPrototypeCollection `json:"pulsar_event_notification_events" validate:"required"`

// Allows users to set headers on API requests
Headers map[string]string
}

// NewReceivePulsarEventNotificationEventsOptions : Instantiate ReceivePulsarEventNotificationEventsOptions
func (*ProjectV1) NewReceivePulsarEventNotificationEventsOptions(pulsarEventNotificationEvents []PulsarEventPrototypeCollection) *ReceivePulsarEventNotificationEventsOptions {
return &ReceivePulsarEventNotificationEventsOptions{
PulsarEventNotificationEvents: pulsarEventNotificationEvents,
}
}

// SetPulsarEventNotificationEvents : Allow user to set PulsarEventNotificationEvents
func (_options *ReceivePulsarEventNotificationEventsOptions) SetPulsarEventNotificationEvents(pulsarEventNotificationEvents []PulsarEventPrototypeCollection) *ReceivePulsarEventNotificationEventsOptions {
_options.PulsarEventNotificationEvents = pulsarEventNotificationEvents
return _options
}

// SetHeaders : Allow user to set Headers
func (options *ReceivePulsarEventNotificationEventsOptions) SetHeaders(param map[string]string) *ReceivePulsarEventNotificationEventsOptions {
options.Headers = param
return options
}

// ReplaceServiceInstanceOptions : The ReplaceServiceInstance options.
type ReplaceServiceInstanceOptions struct {
// The instance_id of a service instance is provided by the IBM Cloud platform.
Expand Down
146 changes: 146 additions & 0 deletions projectv1/project_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5301,6 +5301,112 @@ var _ = Describe(`ProjectV1`, func() {
})
})
})
Describe(`ReceivePulsarEventNotificationEvents(receivePulsarEventNotificationEventsOptions *ReceivePulsarEventNotificationEventsOptions)`, func() {
receivePulsarEventNotificationEventsPath := "/v1/pulsar/event_notification_events"
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(receivePulsarEventNotificationEventsPath))
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())

res.WriteHeader(202)
}))
})
It(`Invoke ReceivePulsarEventNotificationEvents successfully`, func() {
projectService, serviceErr := projectv1.NewProjectV1(&projectv1.ProjectV1Options{
URL: testServer.URL,
Authenticator: &core.NoAuthAuthenticator{},
})
Expect(serviceErr).To(BeNil())
Expect(projectService).ToNot(BeNil())

// Invoke operation with nil options model (negative test)
response, operationErr := projectService.ReceivePulsarEventNotificationEvents(nil)
Expect(operationErr).NotTo(BeNil())
Expect(response).To(BeNil())

// Construct an instance of the PulsarEventPrototypeCollection model
pulsarEventPrototypeCollectionModel := new(projectv1.PulsarEventPrototypeCollection)
pulsarEventPrototypeCollectionModel.EventType = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Timestamp = CreateMockDateTime("2019-01-01T12:00:00.000Z")
pulsarEventPrototypeCollectionModel.Publisher = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.AccountID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Version = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.EventProperties = map[string]interface{}{"anyKey": "anyValue"}
pulsarEventPrototypeCollectionModel.EventID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.SetProperty("foo", core.StringPtr("testString"))

// Construct an instance of the ReceivePulsarEventNotificationEventsOptions model
receivePulsarEventNotificationEventsOptionsModel := new(projectv1.ReceivePulsarEventNotificationEventsOptions)
receivePulsarEventNotificationEventsOptionsModel.PulsarEventNotificationEvents = []projectv1.PulsarEventPrototypeCollection{*pulsarEventPrototypeCollectionModel}
receivePulsarEventNotificationEventsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}

// Invoke operation with valid options model (positive test)
response, operationErr = projectService.ReceivePulsarEventNotificationEvents(receivePulsarEventNotificationEventsOptionsModel)
Expect(operationErr).To(BeNil())
Expect(response).ToNot(BeNil())
})
It(`Invoke ReceivePulsarEventNotificationEvents with error: Operation validation and request error`, func() {
projectService, serviceErr := projectv1.NewProjectV1(&projectv1.ProjectV1Options{
URL: testServer.URL,
Authenticator: &core.NoAuthAuthenticator{},
})
Expect(serviceErr).To(BeNil())
Expect(projectService).ToNot(BeNil())

// Construct an instance of the PulsarEventPrototypeCollection model
pulsarEventPrototypeCollectionModel := new(projectv1.PulsarEventPrototypeCollection)
pulsarEventPrototypeCollectionModel.EventType = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Timestamp = CreateMockDateTime("2019-01-01T12:00:00.000Z")
pulsarEventPrototypeCollectionModel.Publisher = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.AccountID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Version = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.EventProperties = map[string]interface{}{"anyKey": "anyValue"}
pulsarEventPrototypeCollectionModel.EventID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.SetProperty("foo", core.StringPtr("testString"))

// Construct an instance of the ReceivePulsarEventNotificationEventsOptions model
receivePulsarEventNotificationEventsOptionsModel := new(projectv1.ReceivePulsarEventNotificationEventsOptions)
receivePulsarEventNotificationEventsOptionsModel.PulsarEventNotificationEvents = []projectv1.PulsarEventPrototypeCollection{*pulsarEventPrototypeCollectionModel}
receivePulsarEventNotificationEventsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
// Invoke operation with empty URL (negative test)
err := projectService.SetServiceURL("")
Expect(err).To(BeNil())
response, operationErr := projectService.ReceivePulsarEventNotificationEvents(receivePulsarEventNotificationEventsOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
Expect(response).To(BeNil())
// Construct a second instance of the ReceivePulsarEventNotificationEventsOptions model with no property values
receivePulsarEventNotificationEventsOptionsModelNew := new(projectv1.ReceivePulsarEventNotificationEventsOptions)
// Invoke operation with invalid model (negative test)
response, operationErr = projectService.ReceivePulsarEventNotificationEvents(receivePulsarEventNotificationEventsOptionsModelNew)
Expect(operationErr).ToNot(BeNil())
Expect(response).To(BeNil())
})
AfterEach(func() {
testServer.Close()
})
})
})
Describe(`GetHealth(getHealthOptions *GetHealthOptions) - Operation response error`, func() {
getHealthPath := "/v1/health"
Context(`Using mock server endpoint with invalid JSON response`, func() {
Expand Down Expand Up @@ -8886,6 +8992,46 @@ var _ = Describe(`ProjectV1`, func() {
Expect(receivePulsarCatalogEventsOptionsModel.PulsarCatalogEvents).To(Equal([]projectv1.PulsarEventPrototypeCollection{*pulsarEventPrototypeCollectionModel}))
Expect(receivePulsarCatalogEventsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
})
It(`Invoke NewReceivePulsarEventNotificationEventsOptions successfully`, func() {
// Construct an instance of the PulsarEventPrototypeCollection model
pulsarEventPrototypeCollectionModel := new(projectv1.PulsarEventPrototypeCollection)
Expect(pulsarEventPrototypeCollectionModel).ToNot(BeNil())
pulsarEventPrototypeCollectionModel.EventType = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Timestamp = CreateMockDateTime("2019-01-01T12:00:00.000Z")
pulsarEventPrototypeCollectionModel.Publisher = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.AccountID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.Version = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.EventProperties = map[string]interface{}{"anyKey": "anyValue"}
pulsarEventPrototypeCollectionModel.EventID = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.SetProperty("foo", core.StringPtr("testString"))
Expect(pulsarEventPrototypeCollectionModel.EventType).To(Equal(core.StringPtr("testString")))
Expect(pulsarEventPrototypeCollectionModel.Timestamp).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
Expect(pulsarEventPrototypeCollectionModel.Publisher).To(Equal(core.StringPtr("testString")))
Expect(pulsarEventPrototypeCollectionModel.AccountID).To(Equal(core.StringPtr("testString")))
Expect(pulsarEventPrototypeCollectionModel.Version).To(Equal(core.StringPtr("testString")))
Expect(pulsarEventPrototypeCollectionModel.EventProperties).To(Equal(map[string]interface{}{"anyKey": "anyValue"}))
Expect(pulsarEventPrototypeCollectionModel.EventID).To(Equal(core.StringPtr("testString")))
Expect(pulsarEventPrototypeCollectionModel.GetProperties()).ToNot(BeEmpty())
Expect(pulsarEventPrototypeCollectionModel.GetProperty("foo")).To(Equal(core.StringPtr("testString")))

pulsarEventPrototypeCollectionModel.SetProperties(nil)
Expect(pulsarEventPrototypeCollectionModel.GetProperties()).To(BeEmpty())

pulsarEventPrototypeCollectionModelExpectedMap := make(map[string]interface{})
pulsarEventPrototypeCollectionModelExpectedMap["foo"] = core.StringPtr("testString")
pulsarEventPrototypeCollectionModel.SetProperties(pulsarEventPrototypeCollectionModelExpectedMap)
pulsarEventPrototypeCollectionModelActualMap := pulsarEventPrototypeCollectionModel.GetProperties()
Expect(pulsarEventPrototypeCollectionModelActualMap).To(Equal(pulsarEventPrototypeCollectionModelExpectedMap))

// Construct an instance of the ReceivePulsarEventNotificationEventsOptions model
pulsarEventNotificationEvents := []projectv1.PulsarEventPrototypeCollection{}
receivePulsarEventNotificationEventsOptionsModel := projectService.NewReceivePulsarEventNotificationEventsOptions(pulsarEventNotificationEvents)
receivePulsarEventNotificationEventsOptionsModel.SetPulsarEventNotificationEvents([]projectv1.PulsarEventPrototypeCollection{*pulsarEventPrototypeCollectionModel})
receivePulsarEventNotificationEventsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
Expect(receivePulsarEventNotificationEventsOptionsModel).ToNot(BeNil())
Expect(receivePulsarEventNotificationEventsOptionsModel.PulsarEventNotificationEvents).To(Equal([]projectv1.PulsarEventPrototypeCollection{*pulsarEventPrototypeCollectionModel}))
Expect(receivePulsarEventNotificationEventsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
})
It(`Invoke NewReplaceServiceInstanceOptions successfully`, func() {
// Construct an instance of the ReplaceServiceInstanceOptions model
instanceID := "crn:v1:staging:public:project:global:a/4e1c48fcf8ac33c0a2441e4139f189ae:bf40ad13-b107-446a-8286-c6d576183bb1::"
Expand Down

0 comments on commit 4ff6e02

Please sign in to comment.