github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/metadata.go (about)

     1  package ccv3
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
     7  	"code.cloudfoundry.org/cli/resources"
     8  )
     9  
    10  func (client *Client) UpdateResourceMetadata(resource string, resourceGUID string, metadata resources.Metadata) (JobURL, Warnings, error) {
    11  	var params RequestParams
    12  	requestMetadata := resources.ResourceMetadata{Metadata: &metadata}
    13  
    14  	switch resource {
    15  	case "app":
    16  		params = RequestParams{
    17  			RequestName: internal.PatchApplicationRequest,
    18  			RequestBody: requestMetadata,
    19  			URIParams:   internal.Params{"app_guid": resourceGUID},
    20  		}
    21  	case "buildpack":
    22  		params = RequestParams{
    23  			RequestName: internal.PatchBuildpackRequest,
    24  			RequestBody: requestMetadata,
    25  			URIParams:   internal.Params{"buildpack_guid": resourceGUID},
    26  		}
    27  	case "domain":
    28  		params = RequestParams{
    29  			RequestName: internal.PatchDomainRequest,
    30  			RequestBody: requestMetadata,
    31  			URIParams:   internal.Params{"domain_guid": resourceGUID},
    32  		}
    33  	case "org":
    34  		params = RequestParams{
    35  			RequestName: internal.PatchOrganizationRequest,
    36  			RequestBody: requestMetadata,
    37  			URIParams:   internal.Params{"organization_guid": resourceGUID},
    38  		}
    39  	case "route":
    40  		params = RequestParams{
    41  			RequestName: internal.PatchRouteRequest,
    42  			RequestBody: requestMetadata,
    43  			URIParams:   internal.Params{"route_guid": resourceGUID},
    44  		}
    45  	case "service-broker":
    46  		params = RequestParams{
    47  			RequestName: internal.PatchServiceBrokerRequest,
    48  			URIParams:   internal.Params{"service_broker_guid": resourceGUID},
    49  			RequestBody: resources.ResourceMetadata{Metadata: &metadata},
    50  		}
    51  	case "service-instance":
    52  		params = RequestParams{
    53  			RequestName: internal.PatchServiceInstanceRequest,
    54  			URIParams:   internal.Params{"service_instance_guid": resourceGUID},
    55  			RequestBody: resources.ResourceMetadata{Metadata: &metadata},
    56  		}
    57  	case "service-offering":
    58  		params = RequestParams{
    59  			RequestName: internal.PatchServiceOfferingRequest,
    60  			RequestBody: requestMetadata,
    61  			URIParams:   internal.Params{"service_offering_guid": resourceGUID},
    62  		}
    63  	case "service-plan":
    64  		params = RequestParams{
    65  			RequestName: internal.PatchServicePlanRequest,
    66  			RequestBody: requestMetadata,
    67  			URIParams:   internal.Params{"service_plan_guid": resourceGUID},
    68  		}
    69  	case "space":
    70  		params = RequestParams{
    71  			RequestName: internal.PatchSpaceRequest,
    72  			RequestBody: requestMetadata,
    73  			URIParams:   internal.Params{"space_guid": resourceGUID},
    74  		}
    75  	case "stack":
    76  		params = RequestParams{
    77  			RequestName: internal.PatchStackRequest,
    78  			RequestBody: requestMetadata,
    79  			URIParams:   internal.Params{"stack_guid": resourceGUID},
    80  		}
    81  	default:
    82  		return "", nil, fmt.Errorf("unknown resource type (%s) requested", resource)
    83  	}
    84  
    85  	return client.MakeRequest(params)
    86  }