Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete function for AccessPackageResourceRoleScope #245

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion msgraph/accesspackageresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *AccessPackageResourceClient) Get(ctx context.Context, catalogId string,
accessPackageResources := data.AccessPackageResources

if len(accessPackageResources) == 0 {
return nil, status, fmt.Errorf("No accessPackageResource found with catalogId %v and originId %v", catalogId, originId)
return nil, http.StatusNotFound, fmt.Errorf("No accessPackageResource found with catalogId %v and originId %v", catalogId, originId)
}

return &accessPackageResources[0], status, nil
Expand Down
18 changes: 17 additions & 1 deletion msgraph/accesspackageresourcerolescope.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,24 @@ func (c *AccessPackageResourceRoleScopeClient) Get(ctx context.Context, accessPa
}

if accessPackageResourceRoleScope.ID == nil {
return nil, status, fmt.Errorf("AccessPackageResourceRoleScopeClient.BaseClient.Get(): Could not find accessPackageResourceRoleScope ID")
return nil, http.StatusNotFound, fmt.Errorf("AccessPackageResourceRoleScopeClient.BaseClient.Get(): Could not find accessPackageResourceRoleScope ID %s", id)
}

return &accessPackageResourceRoleScope, status, nil
}

// Delete removes a AccessPackageResourceRoleScope.
func (c *AccessPackageResourceRoleScopeClient) Delete(ctx context.Context, accessPackageId string, id string) (int, error) {
_, status, _, err := c.BaseClient.Delete(ctx, DeleteHttpRequestInput{
ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc,
ValidStatusCodes: []int{http.StatusOK},
Uri: Uri{
Entity: fmt.Sprintf("/identityGovernance/entitlementManagement/accessPackages/%s/accessPackageResourceRoleScopes/%s", accessPackageId, id),
},
})
if err != nil {
return status, fmt.Errorf("AccessPackageResourceRoleScopeClient.BaseClient.Delete(): %v", err)
}

return status, nil
}
12 changes: 11 additions & 1 deletion msgraph/accesspackageresourcerolescope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestAccessPackageResourceRoleScopeClient(t *testing.T) {
testAccessPackageResourceRoleScopeClient_Get(t, c, *accessPackageResourceRoleScope.AccessPackageId, *accessPackageResourceRoleScope.ID)
testAccessPackageResourceRoleScopeResource_Get(t, c, *accessPackageResourceRequest.CatalogId, *accessPackageResourceRequest.AccessPackageResource.OriginId)
testAccessPackageResourceRoleScopeClient_List(t, c, *accessPackageResourceRoleScope.AccessPackageId)
testAccessPackageResourceRoleScopeClient_Delete(t, c, *accessPackageResourceRoleScope.AccessPackageId, *accessPackageResourceRoleScope.ID)

// Force-replacement scenario
testAccessPackageResourceRoleScopeAP_Delete(t, c, *accessPackage.ID)
Expand All @@ -93,7 +94,6 @@ func TestAccessPackageResourceRoleScopeClient(t *testing.T) {
},
})

//testAccessPackageResourceRoleScopeClient_Delete(t, c, *accessPackageResourceRoleScope)
//testAccessPackageResourceRequestClient_Delete(t, c, accessPackageResourceRequest)

// Cleanup
Expand Down Expand Up @@ -147,6 +147,16 @@ func testAccessPackageResourceRoleScopeClient_List(t *testing.T, c *test.Test, a
return
}

func testAccessPackageResourceRoleScopeClient_Delete(t *testing.T, c *test.Test, accessPackageId string, id string) {
status, err := c.AccessPackageResourceRoleScopeClient.Delete(c.Context, accessPackageId, id)
if err != nil {
t.Fatalf("AccessPackageResourceRequestClient.Delete(): %v", err)
}
if status < 200 || status >= 300 {
t.Fatalf("AccessPackageResourceRequestClient.Delete(): invalid status: %d", status)
}
}

// AccessPackageResourceRequest

func testAccessPackageResourceRoleScopeResourceRequest_Create(t *testing.T, c *test.Test, a msgraph.AccessPackageResourceRequest, pollForId bool) (accessPackageResourceRequest *msgraph.AccessPackageResourceRequest) {
Expand Down