From 3edc64c63f92a66167be5d440b8693a7dd41db93 Mon Sep 17 00:00:00 2001 From: Charlie Conneely Date: Wed, 11 Sep 2024 16:01:34 +0100 Subject: [PATCH] Small changes --- .../data_source_genesyscloud_simple_routing_queue.go | 8 ++++++-- .../resource_genesyscloud_simple_routing_queue.go | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/genesyscloud/simple_routing_queue/data_source_genesyscloud_simple_routing_queue.go b/genesyscloud/simple_routing_queue/data_source_genesyscloud_simple_routing_queue.go index ed6f9e4a1..755c810ce 100644 --- a/genesyscloud/simple_routing_queue/data_source_genesyscloud_simple_routing_queue.go +++ b/genesyscloud/simple_routing_queue/data_source_genesyscloud_simple_routing_queue.go @@ -25,14 +25,18 @@ func dataSourceSimpleRoutingQueueRead(ctx context.Context, d *schema.ResourceDat // CREATE-TODO 2: Get an instance of our proxy by passing sdkConfig into the method getSimpleRoutingQueueProxy // CREATE-TODO 3: Grab our queue name from the schema.ResourceData object (this step is already complete) + name := d.Get("name").(string) log.Printf("Finding queue by name") return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { + log.Printf(`Retrieving ID of simple routing queue "%s"`, name) // CREATE-TODO 4: Call to the proxy function proxyInstance.getRoutingQueueIdByName(context.Context, string), passing ctx and our name variable // This function returns values in the following order: queueId (string), response (*platformclientv2.APIResponse), err (error), retryable (bool) - // CREATE-TODO 5: If the error is not nil, and retryable equals false, return a resource.NonRetryableError - // to let the user know that an error occurred. If retryable is true, return a resource.RetryableError + // CREATE-TODO 5: If the error is not nil, and retryable equals false, return a retry.NonRetryableError + // to let the user know that an error occurred. If retryable is true, return a retry.RetryableError + // We use the BuildWithRetriesApiDiagnosticError to provide as much info to the user as possible + // E.g. return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("No queue found with name %s", name), resp)) // CREATE-TODO 6: If we made it this far, we can call d.SetId(queueId) and return nil diff --git a/genesyscloud/simple_routing_queue/resource_genesyscloud_simple_routing_queue.go b/genesyscloud/simple_routing_queue/resource_genesyscloud_simple_routing_queue.go index c51ec391d..30c8e37c4 100644 --- a/genesyscloud/simple_routing_queue/resource_genesyscloud_simple_routing_queue.go +++ b/genesyscloud/simple_routing_queue/resource_genesyscloud_simple_routing_queue.go @@ -116,13 +116,15 @@ func updateSimpleRoutingQueue(ctx context.Context, d *schema.ResourceData, meta // CREATE-TODO 2: Create variables for each field in our schema.ResourceData object // CREATE-TODO 3: Create a queue struct using the Genesys Cloud platform go sdk - - log.Println("Updating simple routing queue") + // ** NOTE: We are using Queuerequest this time - not Createqueuerequest ** + // Here is the source code for the struct we will be using - https://github.com/MyPureCloud/platform-client-sdk-go/blob/master/platformclientv2/Queuerequest.go + // (Remember - we only need to worry about the three fields defined in our schema) // CREATE-TODO 4: Call the proxy function updateSimpleRoutingQueue(context.Context, id string, *platformclientv2.Queuerequest) to update our queue // We should handle our error and response objects the same way as in the createSimpleRoutingQueue method above. // We won't be needing the returned Queue object, so an underscore can go in that variables place. If we were to define it, Go would complain that we're not using it, // so this is our way of telling Go that we don't need it. + log.Println("Updating simple routing queue") log.Println("Updated simple routing queue") return readSimpleRoutingQueue(ctx, d, meta)