diff --git a/examples/e2e-tests/kubernetes/release/default/definition.json b/examples/e2e-tests/kubernetes/release/default/definition.json index 8996269740..289c6e5842 100644 --- a/examples/e2e-tests/kubernetes/release/default/definition.json +++ b/examples/e2e-tests/kubernetes/release/default/definition.json @@ -4,6 +4,7 @@ "orchestratorProfile": { "orchestratorType": "Kubernetes", "kubernetesConfig": { + "useManagedIdentity": true, "clusterSubnet": "10.239.0.0/16", "addons": [ { @@ -146,10 +147,6 @@ "adminPassword": "replacepassword1234$", "sshEnabled": true, "enableAutomaticUpdates": false - }, - "servicePrincipalProfile": { - "clientId": "", - "secret": "" } } } diff --git a/pkg/engine/armtype.go b/pkg/engine/armtype.go index 293eb03e36..3fa87c0d18 100644 --- a/pkg/engine/armtype.go +++ b/pkg/engine/armtype.go @@ -10,7 +10,6 @@ import ( "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault" - sysauth "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" @@ -116,7 +115,7 @@ type StorageAccountARM struct { // SystemRoleAssignmentARM embeds the ARMResource type in authorization.SystemRoleAssignment(2018-01-01-preview). type SystemRoleAssignmentARM struct { ARMResource - sysauth.RoleAssignment + authorization.RoleAssignment } // VirtualNetworkARM embeds the ARMResource type in network.VirtualNetwork. diff --git a/pkg/engine/masterarmresources.go b/pkg/engine/masterarmresources.go index e36a95c4e2..fe62a579c2 100644 --- a/pkg/engine/masterarmresources.go +++ b/pkg/engine/masterarmresources.go @@ -4,6 +4,8 @@ package engine import ( + "strings" + "github.com/Azure/aks-engine/pkg/api" "github.com/Azure/go-autorest/autorest/to" ) @@ -120,19 +122,22 @@ func createKubernetesMasterResourcesVMAS(cs *api.ContainerService) []interface{} masterCSE.ARMResource.DependsOn = append(masterCSE.ARMResource.DependsOn, "[concat('Microsoft.KeyVault/vaults/', variables('clusterKeyVaultName'))]") } - // TODO: This is only necessary if the resource group of the masters is different from the RG of the node pool - // subnet. But when we generate the template we don't know to which RG it will be deployed to. To solve this we - // would have to add the necessary condition into the template. For the resources we can use the `condition` field - // but how can we conditionally declare the dependencies? Perhaps by creating a variable for the dependency array - // and conditionally adding more dependencies. - if kubernetesConfig.SystemAssignedIDEnabled() && - // The fix for ticket 2373 is only available for individual VMs / AvailabilitySet. - cs.Properties.MasterProfile.IsAvailabilitySet() { - masterRoleAssignmentForAgentPools := createKubernetesMasterRoleAssignmentForAgentPools(cs.Properties.MasterProfile, cs.Properties.AgentPoolProfiles) - - for _, assignmentForAgentPool := range masterRoleAssignmentForAgentPools { - masterResources = append(masterResources, assignmentForAgentPool) - masterCSE.ARMResource.DependsOn = append(masterCSE.ARMResource.DependsOn, *assignmentForAgentPool.Name) + // If the control plane is in a discrete VNET + if hasDistinctControlPlaneVNET(cs) { + // TODO: This is only necessary if the resource group of the masters is different from the RG of the node pool + // subnet. But when we generate the template we don't know to which RG it will be deployed to. To solve this we + // would have to add the necessary condition into the template. For the resources we can use the `condition` field + // but how can we conditionally declare the dependencies? Perhaps by creating a variable for the dependency array + // and conditionally adding more dependencies. + if kubernetesConfig.SystemAssignedIDEnabled() && + // The fix for ticket 2373 is only available for individual VMs / AvailabilitySet. + cs.Properties.MasterProfile.IsAvailabilitySet() { + masterRoleAssignmentForAgentPools := createKubernetesMasterRoleAssignmentForAgentPools(cs.Properties.MasterProfile, cs.Properties.AgentPoolProfiles) + + for _, assignmentForAgentPool := range masterRoleAssignmentForAgentPools { + masterResources = append(masterResources, assignmentForAgentPool) + masterCSE.ARMResource.DependsOn = append(masterCSE.ARMResource.DependsOn, *assignmentForAgentPool.Name) + } } } @@ -207,3 +212,33 @@ func createKubernetesMasterResourcesVMSS(cs *api.ContainerService) []interface{} return masterResources } + +// hasDistinctControlPlaneVNET returns whether or not the VNET config of the control plane is distinct from any one node pool +// If the VnetSubnetID string is malformed in either the MasterProfile or any AgentPoolProfile, we return false +func hasDistinctControlPlaneVNET(cs *api.ContainerService) bool { + var controlPlaneVNETResourceURI string + if cs.Properties.MasterProfile.VnetSubnetID != "" { + controlPlaneSubnetElements := strings.Split(cs.Properties.MasterProfile.VnetSubnetID, "/") + if len(controlPlaneSubnetElements) >= 9 { + controlPlaneVNETResourceURI = strings.Join(controlPlaneSubnetElements[:9], "/") + } else { + return false + } + } + for _, agentPool := range cs.Properties.AgentPoolProfiles { + if agentPool.VnetSubnetID != "" { + nodePoolSubnetElements := strings.Split(agentPool.VnetSubnetID, "/") + if len(nodePoolSubnetElements) < 9 { + return false + } + if strings.Join(nodePoolSubnetElements[:9], "/") != controlPlaneVNETResourceURI { + return true + } + } else { + if cs.Properties.MasterProfile.VnetSubnetID != "" { + return true + } + } + } + return false +} diff --git a/pkg/engine/masterarmresources_test.go b/pkg/engine/masterarmresources_test.go index 0c7b254db8..b568c5e86c 100644 --- a/pkg/engine/masterarmresources_test.go +++ b/pkg/engine/masterarmresources_test.go @@ -853,3 +853,167 @@ func TestCreateKubernetesMasterResourcesVMSS(t *testing.T) { t.Errorf("unexpected error while comparing ARM resources: %s", diff) } } + +func TestHasDistinctControlPlaneVNET(t *testing.T) { + testcases := []struct { + name string + cs *api.ContainerService + expected bool + }{ + { + name: "No VNET specified", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{}, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + }, + }, + }, + }, + expected: false, + }, + { + name: "Control Plane has VNET", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{ + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET_NAME", + }, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + }, + }, + }, + }, + expected: true, + }, + { + name: "Node pool has VNET", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{}, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET_NAME", + }, + }, + }, + }, + expected: true, + }, + { + name: "VNET is shared", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{ + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET_NAME", + }, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET_NAME", + }, + { + Name: "agentpool2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET_NAME", + }, + }, + }, + }, + expected: false, + }, + { + name: "Heterogeneous VNETs", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{ + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME1/subnets/SUBNET_NAME", + }, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME3/subnets/SUBNET_NAME", + }, + }, + }, + }, + expected: true, + }, + { + name: "Same node pool VNETs, different control plane VNET", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{ + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME1/subnets/SUBNET_NAME", + }, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool3", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool4", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + }, + }, + }, + expected: true, + }, + { + name: "All have the same VNET except one node pool", + cs: &api.ContainerService{ + Properties: &api.Properties{ + MasterProfile: &api.MasterProfile{ + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + AgentPoolProfiles: []*api.AgentPoolProfile{ + { + Name: "agentpool1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool3", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME1/subnets/SUBNET_NAME", + }, + { + Name: "agentpool4", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + { + Name: "agentpool5", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME2/subnets/SUBNET_NAME", + }, + }, + }, + }, + expected: true, + }, + } + for _, testcase := range testcases { + actual := hasDistinctControlPlaneVNET(testcase.cs) + if testcase.expected != actual { + t.Errorf("Test \"%s\": expected hasDistinctControlPlaneVNET() to return %t, but got %t . ", testcase.name, testcase.expected, actual) + } + } +} diff --git a/pkg/engine/systemroleassignments.go b/pkg/engine/systemroleassignments.go index fa3c4a33aa..e67aef0e9b 100644 --- a/pkg/engine/systemroleassignments.go +++ b/pkg/engine/systemroleassignments.go @@ -5,11 +5,12 @@ package engine import ( "fmt" + "strings" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" "github.com/Azure/aks-engine/pkg/api" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/Azure/go-autorest/autorest/to" ) @@ -32,6 +33,7 @@ func createVMASRoleAssignment() SystemRoleAssignmentARM { systemRoleAssignment.RoleAssignmentPropertiesWithScope = &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('contributorRoleDefinitionId')]"), PrincipalID: to.StringPtr("[reference(concat('Microsoft.Compute/virtualMachines/', variables('masterVMNamePrefix'), copyIndex(variables('masterOffset'))), '2017-03-30', 'Full').identity.principalId]"), + PrincipalType: authorization.ServicePrincipal, } return systemRoleAssignment } @@ -56,6 +58,7 @@ func createAgentVMASSysRoleAssignment(profile *api.AgentPoolProfile) SystemRoleA systemRoleAssignment.RoleAssignmentPropertiesWithScope = &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('readerRoleDefinitionId')]"), PrincipalID: to.StringPtr(fmt.Sprintf("[reference(concat('Microsoft.Compute/virtualMachines/', variables('%[1]sVMNamePrefix'), copyIndex(variables('%[1]sOffset'))), '2017-03-30', 'Full').identity.principalId]", profile.Name)), + PrincipalType: authorization.ServicePrincipal, } return systemRoleAssignment @@ -76,6 +79,7 @@ func createAgentVMSSSysRoleAssignment(profile *api.AgentPoolProfile) SystemRoleA systemRoleAssignment.RoleAssignmentPropertiesWithScope = &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('readerRoleDefinitionId')]"), PrincipalID: to.StringPtr(fmt.Sprintf("[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('%[1]sVMNamePrefix')), '2017-03-30', 'Full').identity.principalId]", profile.Name)), + PrincipalType: authorization.ServicePrincipal, } return systemRoleAssignment @@ -88,13 +92,35 @@ func createKubernetesMasterRoleAssignmentForAgentPools(masterProfile *api.Master dependenciesToMasterVms[masterIdx] = fmt.Sprintf("[concat(variables('masterVMNamePrefix'), %d)]", masterIdx) } - var roleAssignmentsForAllAgentPools = make([]DeploymentWithResourceGroupARM, len(agentPoolProfiles)) + roleAssignmentsForAllAgentPools := []DeploymentWithResourceGroupARM{} // The following is based on: // * https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/role-based-access-control/role-assignments-template.md#create-a-role-assignment-at-a-resource-scope // * https://github.com/Azure/azure-quickstart-templates/blob/master/201-rbac-builtinrole-multipleVMs/azuredeploy.json#L79 - for agentPoolIdx, agentPool := range agentPoolProfiles { + + // We're gonna keep track of distinct VNETs in use across all our node pools; + // we only want to define master VM --> VNET role assignments once per VNET. + // If our cluster configuration includes more than one pool sharing a common VNET, + // we define the master VM --> VNET role assignments (one per master VM) just once for those pools + var vnetInCluster = struct{}{} + vnets := make(map[string]struct{}) + for _, agentPool := range agentPoolProfiles { var roleAssignments = make([]interface{}, masterProfile.Count) + subnetElements := strings.Split(agentPool.VnetSubnetID, "/") + // We expect a very specific string format for the VnetSubnetID property; + // if it can't be split into at least 9 "/"-delimited elements, + // then we should assume that our role assignment composition below will be malformed, + // and so we simply skip assigning a role assigment for this pool. + // This should never happen, but this defensive posture ensures no code panic execution path + // // when we statically grab the first 9 elements (`subnetElements[:9]` below) + if len(subnetElements) < 9 { + continue + } + vnetResourceURI := strings.Join(subnetElements[:9], "/") + if _, ok := vnets[vnetResourceURI]; ok { + continue + } + vnets[vnetResourceURI] = vnetInCluster for masterIdx := 0; masterIdx < masterProfile.Count; masterIdx++ { masterVMReference := fmt.Sprintf("reference(resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', concat(variables('masterVMNamePrefix'), %d)), '2017-03-30', 'Full').identity.principalId", masterIdx) @@ -110,7 +136,7 @@ func createKubernetesMasterRoleAssignmentForAgentPools(masterProfile *api.Master }, */ }, - // Reference to the subnet of the worker VMs: + // Reference to the VNET of the worker VMs: RoleAssignment: authorization.RoleAssignment{ Name: to.StringPtr(fmt.Sprintf("[concat(variables('%sVnet'), '/Microsoft.Authorization/', guid(uniqueString(%s)))]", agentPool.Name, masterVMReference)), Type: to.StringPtr("Microsoft.Network/virtualNetworks/providers/roleAssignments"), @@ -146,7 +172,7 @@ func createKubernetesMasterRoleAssignmentForAgentPools(masterProfile *api.Master }, } - roleAssignmentsForAllAgentPools[agentPoolIdx] = roleAssignmentsForAgentPoolSubDeployment + roleAssignmentsForAllAgentPools = append(roleAssignmentsForAllAgentPools, roleAssignmentsForAgentPoolSubDeployment) } return roleAssignmentsForAllAgentPools diff --git a/pkg/engine/systemroleassignments_test.go b/pkg/engine/systemroleassignments_test.go index 3c5e5e3593..9d77445e6e 100644 --- a/pkg/engine/systemroleassignments_test.go +++ b/pkg/engine/systemroleassignments_test.go @@ -9,7 +9,7 @@ import ( "github.com/Azure/aks-engine/pkg/api" "github.com/google/go-cmp/cmp" - "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" + "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" "github.com/Azure/go-autorest/autorest/to" ) @@ -35,6 +35,7 @@ func TestCreateVmasRoleAssignment(t *testing.T) { RoleAssignmentPropertiesWithScope: &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('contributorRoleDefinitionId')]"), PrincipalID: to.StringPtr("[reference(concat('Microsoft.Compute/virtualMachines/', variables('masterVMNamePrefix'), copyIndex(variables('masterOffset'))), '2017-03-30', 'Full').identity.principalId]"), + PrincipalType: authorization.ServicePrincipal, }, }, } @@ -70,6 +71,7 @@ func TestCreateAgentVmasSysRoleAssignment(t *testing.T) { RoleAssignmentPropertiesWithScope: &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('readerRoleDefinitionId')]"), PrincipalID: to.StringPtr("[reference(concat('Microsoft.Compute/virtualMachines/', variables('fooprofileVMNamePrefix'), copyIndex(variables('fooprofileOffset'))), '2017-03-30', 'Full').identity.principalId]"), + PrincipalType: authorization.ServicePrincipal, }, }, } @@ -102,6 +104,7 @@ func TestCreateAgentVmssSysRoleAssignment(t *testing.T) { RoleAssignmentPropertiesWithScope: &authorization.RoleAssignmentPropertiesWithScope{ RoleDefinitionID: to.StringPtr("[variables('readerRoleDefinitionId')]"), PrincipalID: to.StringPtr("[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('fooprofileVMNamePrefix')), '2017-03-30', 'Full').identity.principalId]"), + PrincipalType: authorization.ServicePrincipal, }, }, } @@ -118,11 +121,14 @@ func TestCreateKubernetesMasterRoleAssignmentForAgentPools(t *testing.T) { masterProfile := &api.MasterProfile{ Count: 2, } + // Two pools sharing a common VNET agentProfile1 := &api.AgentPoolProfile{ - Name: "agentProfile1", + Name: "agentProfile1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET1_NAME", } agentProfile2 := &api.AgentPoolProfile{ - Name: "agentProfile2", + Name: "agentProfile2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/SUBNET2_NAME", } actual := createKubernetesMasterRoleAssignmentForAgentPools(masterProfile, []*api.AgentPoolProfile{agentProfile1, agentProfile2}) @@ -177,6 +183,76 @@ func TestCreateKubernetesMasterRoleAssignmentForAgentPools(t *testing.T) { }, }, }, + } + + diff := cmp.Diff(actual, expected) + + if diff != "" { + t.Errorf("unexpected diff while comparing: %s", diff) + } + + // Two pools with discrete VNETs + agentProfile1 = &api.AgentPoolProfile{ + Name: "agentProfile1", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET1_NAME/subnets/SUBNET1_NAME", + } + agentProfile2 = &api.AgentPoolProfile{ + Name: "agentProfile2", + VnetSubnetID: "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/VNET2_NAME/subnets/SUBNET2_NAME", + } + + actual = createKubernetesMasterRoleAssignmentForAgentPools(masterProfile, []*api.AgentPoolProfile{agentProfile1, agentProfile2}) + + expected = []DeploymentWithResourceGroupARM{ + { + DeploymentARMResource: DeploymentARMResource{ + APIVersion: "2017-05-10", + DependsOn: []string{ + "[concat(variables('masterVMNamePrefix'), 0)]", + "[concat(variables('masterVMNamePrefix'), 1)]", + }, + }, + ResourceGroup: to.StringPtr("[variables('agentProfile1SubnetResourceGroup')]"), + DeploymentExtended: resources.DeploymentExtended{ + Name: to.StringPtr("[concat('masterMsiRoleAssignment-', variables('agentProfile1VMNamePrefix'))]"), + Type: to.StringPtr("Microsoft.Resources/deployments"), + Properties: &resources.DeploymentPropertiesExtended{ + Mode: "Incremental", + Template: map[string]interface{}{ + "resources": []interface{}{ + SystemRoleAssignmentARM{ + ARMResource: ARMResource{ + APIVersion: "[variables('apiVersionAuthorizationSystem')]", + }, + RoleAssignment: authorization.RoleAssignment{ + Name: to.StringPtr("[concat(variables('agentProfile1Vnet'), '/Microsoft.Authorization/', guid(uniqueString(reference(resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', concat(variables('masterVMNamePrefix'), 0)), '2017-03-30', 'Full').identity.principalId)))]"), + Type: to.StringPtr("Microsoft.Network/virtualNetworks/providers/roleAssignments"), + RoleAssignmentPropertiesWithScope: &authorization.RoleAssignmentPropertiesWithScope{ + RoleDefinitionID: to.StringPtr("[variables('networkContributorRoleDefinitionId')]"), + PrincipalID: to.StringPtr("[reference(resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', concat(variables('masterVMNamePrefix'), 0)), '2017-03-30', 'Full').identity.principalId]"), + }, + }, + }, + SystemRoleAssignmentARM{ + ARMResource: ARMResource{ + APIVersion: "[variables('apiVersionAuthorizationSystem')]", + }, + RoleAssignment: authorization.RoleAssignment{ + Name: to.StringPtr("[concat(variables('agentProfile1Vnet'), '/Microsoft.Authorization/', guid(uniqueString(reference(resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', concat(variables('masterVMNamePrefix'), 1)), '2017-03-30', 'Full').identity.principalId)))]"), + Type: to.StringPtr("Microsoft.Network/virtualNetworks/providers/roleAssignments"), + RoleAssignmentPropertiesWithScope: &authorization.RoleAssignmentPropertiesWithScope{ + RoleDefinitionID: to.StringPtr("[variables('networkContributorRoleDefinitionId')]"), + PrincipalID: to.StringPtr("[reference(resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', concat(variables('masterVMNamePrefix'), 1)), '2017-03-30', 'Full').identity.principalId]"), + }, + }, + }, + }, + "contentVersion": "1.0.0.0", + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + }, + }, + }, + }, { DeploymentARMResource: DeploymentARMResource{ APIVersion: "2017-05-10", @@ -228,7 +304,7 @@ func TestCreateKubernetesMasterRoleAssignmentForAgentPools(t *testing.T) { }, } - diff := cmp.Diff(actual, expected) + diff = cmp.Diff(actual, expected) if diff != "" { t.Errorf("unexpected diff while comparing: %s", diff) diff --git a/test/e2e/azure/cli.go b/test/e2e/azure/cli.go index 34c4fb1d4d..5c256e6c57 100644 --- a/test/e2e/azure/cli.go +++ b/test/e2e/azure/cli.go @@ -5,6 +5,7 @@ package azure import ( + "bytes" "context" "encoding/json" "fmt" @@ -278,16 +279,27 @@ func (a *Account) CreateDeployment(name string, e *engine.Engine) error { } }() - cmd := exec.Command("az", "deployment", "group", "create", + azArgsStringSlice := []string{"deployment", "group", "create", "--name", d.Name, "--resource-group", a.ResourceGroup.Name, "--template-file", e.Config.GeneratedTemplatePath, - "--parameters", e.Config.GeneratedParametersPath) + "--parameters", e.Config.GeneratedParametersPath} + cmd := exec.Command("az", azArgsStringSlice...) util.PrintCommand(cmd) out, err := cmd.CombinedOutput() if err != nil { log.Printf("\nError from deployment for %s in resource group %s:%s\n", d.Name, a.ResourceGroup.Name, err) log.Printf("Command Output: %s\n", out) + if bytes.Contains(out, []byte("PrincipalNotFound")) { + for err != nil { + cmd = exec.Command("az", azArgsStringSlice...) + util.PrintCommand(cmd) + out, err = cmd.CombinedOutput() + if err != nil { + log.Printf("Command Output: %s\n", out) + } + } + } return err } quit <- true diff --git a/test/e2e/engine/template.go b/test/e2e/engine/template.go index 7db51a318b..0034f81e9c 100644 --- a/test/e2e/engine/template.go +++ b/test/e2e/engine/template.go @@ -139,7 +139,7 @@ func Build(cfg *config.Config, masterSubnetID string, agentSubnetIDs []string, i isAzureStackCloud = true } - if config.ClientID != "" && config.ClientSecret != "" { + if config.ClientID != "" && config.ClientSecret != "" && prop.OrchestratorProfile.KubernetesConfig != nil && !prop.OrchestratorProfile.KubernetesConfig.UseManagedIdentity { if !prop.IsAzureStackCloud() { prop.ServicePrincipalProfile = &vlabs.ServicePrincipalProfile{ ClientID: config.ClientID, diff --git a/test/e2e/test_cluster_configs/everything.json b/test/e2e/test_cluster_configs/everything.json index 7d832dde6b..e480b1c0c5 100644 --- a/test/e2e/test_cluster_configs/everything.json +++ b/test/e2e/test_cluster_configs/everything.json @@ -15,6 +15,7 @@ "orchestratorProfile": { "orchestratorType": "Kubernetes", "kubernetesConfig": { + "useManagedIdentity": true, "containerRuntimeConfig": { "dataDir": "/mnt/docker" }, @@ -68,7 +69,7 @@ { "name": "node-problem-detector", "enabled": true - } + } ], "components": [ { @@ -159,10 +160,6 @@ "adminPassword": "replacepassword1234$", "enableAutomaticUpdates": false, "sshEnabled": true - }, - "servicePrincipalProfile": { - "clientId": "", - "secret": "" } } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go deleted file mode 100644 index 338eb8e030..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/classicadministrators.go +++ /dev/null @@ -1,152 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ClassicAdministratorsClient is the client for the ClassicAdministrators methods of the Authorization service. -type ClassicAdministratorsClient struct { - BaseClient -} - -// NewClassicAdministratorsClient creates an instance of the ClassicAdministratorsClient client. -func NewClassicAdministratorsClient(subscriptionID string) ClassicAdministratorsClient { - return NewClassicAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewClassicAdministratorsClientWithBaseURI creates an instance of the ClassicAdministratorsClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewClassicAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ClassicAdministratorsClient { - return ClassicAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List gets service administrator, account administrator, and co-administrators for the subscription. -func (client ClassicAdministratorsClient) List(ctx context.Context) (result ClassicAdministratorListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List") - defer func() { - sc := -1 - if result.calr.Response.Response != nil { - sc = result.calr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.calr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request") - return - } - - result.calr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ClassicAdministratorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-06-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ClassicAdministratorsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ClassicAdministratorsClient) ListResponder(resp *http.Response) (result ClassicAdministratorListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ClassicAdministratorsClient) listNextResults(ctx context.Context, lastResults ClassicAdministratorListResult) (result ClassicAdministratorListResult, err error) { - req, err := lastResults.classicAdministratorListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ClassicAdministratorsClient) ListComplete(ctx context.Context) (result ClassicAdministratorListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go deleted file mode 100644 index 1958a67601..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/client.go +++ /dev/null @@ -1,52 +0,0 @@ -// Package authorization implements the Azure ARM Authorization service API version . -// -// -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Authorization - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Authorization. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go deleted file mode 100644 index 031aea0222..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/globaladministrator.go +++ /dev/null @@ -1,109 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// GlobalAdministratorClient is the client for the GlobalAdministrator methods of the Authorization service. -type GlobalAdministratorClient struct { - BaseClient -} - -// NewGlobalAdministratorClient creates an instance of the GlobalAdministratorClient client. -func NewGlobalAdministratorClient(subscriptionID string) GlobalAdministratorClient { - return NewGlobalAdministratorClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewGlobalAdministratorClientWithBaseURI creates an instance of the GlobalAdministratorClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewGlobalAdministratorClientWithBaseURI(baseURI string, subscriptionID string) GlobalAdministratorClient { - return GlobalAdministratorClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ElevateAccess elevates access for a Global Administrator. -func (client GlobalAdministratorClient) ElevateAccess(ctx context.Context) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GlobalAdministratorClient.ElevateAccess") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ElevateAccessPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", nil, "Failure preparing request") - return - } - - resp, err := client.ElevateAccessSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure sending request") - return - } - - result, err = client.ElevateAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure responding to request") - } - - return -} - -// ElevateAccessPreparer prepares the ElevateAccess request. -func (client GlobalAdministratorClient) ElevateAccessPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2015-07-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Authorization/elevateAccess"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ElevateAccessSender sends the ElevateAccess request. The method will close the -// http.Response Body if it receives an error. -func (client GlobalAdministratorClient) ElevateAccessSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ElevateAccessResponder handles the response to the ElevateAccess request. The method always -// closes the http.Response Body. -func (client GlobalAdministratorClient) ElevateAccessResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go deleted file mode 100644 index 0a03dbb032..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/models.go +++ /dev/null @@ -1,1143 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization" - -// ClassicAdministrator classic Administrators -type ClassicAdministrator struct { - // ID - The ID of the administrator. - ID *string `json:"id,omitempty"` - // Name - The name of the administrator. - Name *string `json:"name,omitempty"` - // Type - The type of the administrator. - Type *string `json:"type,omitempty"` - // ClassicAdministratorProperties - Properties for the classic administrator. - *ClassicAdministratorProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClassicAdministrator. -func (ca ClassicAdministrator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ca.ID != nil { - objectMap["id"] = ca.ID - } - if ca.Name != nil { - objectMap["name"] = ca.Name - } - if ca.Type != nil { - objectMap["type"] = ca.Type - } - if ca.ClassicAdministratorProperties != nil { - objectMap["properties"] = ca.ClassicAdministratorProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ClassicAdministrator struct. -func (ca *ClassicAdministrator) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ca.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ca.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ca.Type = &typeVar - } - case "properties": - if v != nil { - var classicAdministratorProperties ClassicAdministratorProperties - err = json.Unmarshal(*v, &classicAdministratorProperties) - if err != nil { - return err - } - ca.ClassicAdministratorProperties = &classicAdministratorProperties - } - } - } - - return nil -} - -// ClassicAdministratorListResult classicAdministrator list result information. -type ClassicAdministratorListResult struct { - autorest.Response `json:"-"` - // Value - An array of administrators. - Value *[]ClassicAdministrator `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ClassicAdministratorListResultIterator provides access to a complete listing of ClassicAdministrator -// values. -type ClassicAdministratorListResultIterator struct { - i int - page ClassicAdministratorListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ClassicAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ClassicAdministratorListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ClassicAdministratorListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ClassicAdministratorListResultIterator) Response() ClassicAdministratorListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ClassicAdministratorListResultIterator) Value() ClassicAdministrator { - if !iter.page.NotDone() { - return ClassicAdministrator{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ClassicAdministratorListResultIterator type. -func NewClassicAdministratorListResultIterator(page ClassicAdministratorListResultPage) ClassicAdministratorListResultIterator { - return ClassicAdministratorListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (calr ClassicAdministratorListResult) IsEmpty() bool { - return calr.Value == nil || len(*calr.Value) == 0 -} - -// classicAdministratorListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (calr ClassicAdministratorListResult) classicAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { - if calr.NextLink == nil || len(to.String(calr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(calr.NextLink))) -} - -// ClassicAdministratorListResultPage contains a page of ClassicAdministrator values. -type ClassicAdministratorListResultPage struct { - fn func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error) - calr ClassicAdministratorListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ClassicAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.calr) - if err != nil { - return err - } - page.calr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ClassicAdministratorListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ClassicAdministratorListResultPage) NotDone() bool { - return !page.calr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ClassicAdministratorListResultPage) Response() ClassicAdministratorListResult { - return page.calr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ClassicAdministratorListResultPage) Values() []ClassicAdministrator { - if page.calr.IsEmpty() { - return nil - } - return *page.calr.Value -} - -// Creates a new instance of the ClassicAdministratorListResultPage type. -func NewClassicAdministratorListResultPage(getNextPage func(context.Context, ClassicAdministratorListResult) (ClassicAdministratorListResult, error)) ClassicAdministratorListResultPage { - return ClassicAdministratorListResultPage{fn: getNextPage} -} - -// ClassicAdministratorProperties classic Administrator properties. -type ClassicAdministratorProperties struct { - // EmailAddress - The email address of the administrator. - EmailAddress *string `json:"emailAddress,omitempty"` - // Role - The role of the administrator. - Role *string `json:"role,omitempty"` -} - -// Permission role definition permissions. -type Permission struct { - // Actions - Allowed actions. - Actions *[]string `json:"actions,omitempty"` - // NotActions - Denied actions. - NotActions *[]string `json:"notActions,omitempty"` - // DataActions - Allowed Data actions. - DataActions *[]string `json:"dataActions,omitempty"` - // NotDataActions - Denied Data actions. - NotDataActions *[]string `json:"notDataActions,omitempty"` -} - -// PermissionGetResult permissions information. -type PermissionGetResult struct { - autorest.Response `json:"-"` - // Value - An array of permissions. - Value *[]Permission `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// PermissionGetResultIterator provides access to a complete listing of Permission values. -type PermissionGetResultIterator struct { - i int - page PermissionGetResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *PermissionGetResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *PermissionGetResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter PermissionGetResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter PermissionGetResultIterator) Response() PermissionGetResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter PermissionGetResultIterator) Value() Permission { - if !iter.page.NotDone() { - return Permission{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the PermissionGetResultIterator type. -func NewPermissionGetResultIterator(page PermissionGetResultPage) PermissionGetResultIterator { - return PermissionGetResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (pgr PermissionGetResult) IsEmpty() bool { - return pgr.Value == nil || len(*pgr.Value) == 0 -} - -// permissionGetResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (pgr PermissionGetResult) permissionGetResultPreparer(ctx context.Context) (*http.Request, error) { - if pgr.NextLink == nil || len(to.String(pgr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(pgr.NextLink))) -} - -// PermissionGetResultPage contains a page of Permission values. -type PermissionGetResultPage struct { - fn func(context.Context, PermissionGetResult) (PermissionGetResult, error) - pgr PermissionGetResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *PermissionGetResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionGetResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.pgr) - if err != nil { - return err - } - page.pgr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *PermissionGetResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page PermissionGetResultPage) NotDone() bool { - return !page.pgr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page PermissionGetResultPage) Response() PermissionGetResult { - return page.pgr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page PermissionGetResultPage) Values() []Permission { - if page.pgr.IsEmpty() { - return nil - } - return *page.pgr.Value -} - -// Creates a new instance of the PermissionGetResultPage type. -func NewPermissionGetResultPage(getNextPage func(context.Context, PermissionGetResult) (PermissionGetResult, error)) PermissionGetResultPage { - return PermissionGetResultPage{fn: getNextPage} -} - -// ProviderOperation operation -type ProviderOperation struct { - // Name - The operation name. - Name *string `json:"name,omitempty"` - // DisplayName - The operation display name. - DisplayName *string `json:"displayName,omitempty"` - // Description - The operation description. - Description *string `json:"description,omitempty"` - // Origin - The operation origin. - Origin *string `json:"origin,omitempty"` - // Properties - The operation properties. - Properties interface{} `json:"properties,omitempty"` - // IsDataAction - The dataAction flag to specify the operation type. - IsDataAction *bool `json:"isDataAction,omitempty"` -} - -// ProviderOperationsMetadata provider Operations metadata -type ProviderOperationsMetadata struct { - autorest.Response `json:"-"` - // ID - The provider id. - ID *string `json:"id,omitempty"` - // Name - The provider name. - Name *string `json:"name,omitempty"` - // Type - The provider type. - Type *string `json:"type,omitempty"` - // DisplayName - The provider display name. - DisplayName *string `json:"displayName,omitempty"` - // ResourceTypes - The provider resource types - ResourceTypes *[]ResourceType `json:"resourceTypes,omitempty"` - // Operations - The provider operations. - Operations *[]ProviderOperation `json:"operations,omitempty"` -} - -// ProviderOperationsMetadataListResult provider operations metadata list -type ProviderOperationsMetadataListResult struct { - autorest.Response `json:"-"` - // Value - The list of providers. - Value *[]ProviderOperationsMetadata `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// ProviderOperationsMetadataListResultIterator provides access to a complete listing of -// ProviderOperationsMetadata values. -type ProviderOperationsMetadataListResultIterator struct { - i int - page ProviderOperationsMetadataListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ProviderOperationsMetadataListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ProviderOperationsMetadataListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ProviderOperationsMetadataListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ProviderOperationsMetadataListResultIterator) Response() ProviderOperationsMetadataListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ProviderOperationsMetadataListResultIterator) Value() ProviderOperationsMetadata { - if !iter.page.NotDone() { - return ProviderOperationsMetadata{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ProviderOperationsMetadataListResultIterator type. -func NewProviderOperationsMetadataListResultIterator(page ProviderOperationsMetadataListResultPage) ProviderOperationsMetadataListResultIterator { - return ProviderOperationsMetadataListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (pomlr ProviderOperationsMetadataListResult) IsEmpty() bool { - return pomlr.Value == nil || len(*pomlr.Value) == 0 -} - -// providerOperationsMetadataListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (pomlr ProviderOperationsMetadataListResult) providerOperationsMetadataListResultPreparer(ctx context.Context) (*http.Request, error) { - if pomlr.NextLink == nil || len(to.String(pomlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(pomlr.NextLink))) -} - -// ProviderOperationsMetadataListResultPage contains a page of ProviderOperationsMetadata values. -type ProviderOperationsMetadataListResultPage struct { - fn func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error) - pomlr ProviderOperationsMetadataListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ProviderOperationsMetadataListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.pomlr) - if err != nil { - return err - } - page.pomlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ProviderOperationsMetadataListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ProviderOperationsMetadataListResultPage) NotDone() bool { - return !page.pomlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ProviderOperationsMetadataListResultPage) Response() ProviderOperationsMetadataListResult { - return page.pomlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ProviderOperationsMetadataListResultPage) Values() []ProviderOperationsMetadata { - if page.pomlr.IsEmpty() { - return nil - } - return *page.pomlr.Value -} - -// Creates a new instance of the ProviderOperationsMetadataListResultPage type. -func NewProviderOperationsMetadataListResultPage(getNextPage func(context.Context, ProviderOperationsMetadataListResult) (ProviderOperationsMetadataListResult, error)) ProviderOperationsMetadataListResultPage { - return ProviderOperationsMetadataListResultPage{fn: getNextPage} -} - -// ResourceType resource Type -type ResourceType struct { - // Name - The resource type name. - Name *string `json:"name,omitempty"` - // DisplayName - The resource type display name. - DisplayName *string `json:"displayName,omitempty"` - // Operations - The resource type operations. - Operations *[]ProviderOperation `json:"operations,omitempty"` -} - -// RoleAssignment role Assignments -type RoleAssignment struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The role assignment ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The role assignment name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The role assignment type. - Type *string `json:"type,omitempty"` - // RoleAssignmentPropertiesWithScope - Role assignment properties. - *RoleAssignmentPropertiesWithScope `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleAssignment. -func (ra RoleAssignment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ra.RoleAssignmentPropertiesWithScope != nil { - objectMap["properties"] = ra.RoleAssignmentPropertiesWithScope - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleAssignment struct. -func (ra *RoleAssignment) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ra.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ra.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ra.Type = &typeVar - } - case "properties": - if v != nil { - var roleAssignmentPropertiesWithScope RoleAssignmentPropertiesWithScope - err = json.Unmarshal(*v, &roleAssignmentPropertiesWithScope) - if err != nil { - return err - } - ra.RoleAssignmentPropertiesWithScope = &roleAssignmentPropertiesWithScope - } - } - } - - return nil -} - -// RoleAssignmentCreateParameters role assignment create parameters. -type RoleAssignmentCreateParameters struct { - // RoleAssignmentProperties - Role assignment properties. - *RoleAssignmentProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleAssignmentCreateParameters. -func (racp RoleAssignmentCreateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if racp.RoleAssignmentProperties != nil { - objectMap["properties"] = racp.RoleAssignmentProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleAssignmentCreateParameters struct. -func (racp *RoleAssignmentCreateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var roleAssignmentProperties RoleAssignmentProperties - err = json.Unmarshal(*v, &roleAssignmentProperties) - if err != nil { - return err - } - racp.RoleAssignmentProperties = &roleAssignmentProperties - } - } - } - - return nil -} - -// RoleAssignmentFilter role Assignments filter -type RoleAssignmentFilter struct { - // PrincipalID - Returns role assignment of the specific principal. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The Delegation flag for the role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleAssignmentListResult role assignment list operation result. -type RoleAssignmentListResult struct { - autorest.Response `json:"-"` - // Value - Role assignment list. - Value *[]RoleAssignment `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// RoleAssignmentListResultIterator provides access to a complete listing of RoleAssignment values. -type RoleAssignmentListResultIterator struct { - i int - page RoleAssignmentListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RoleAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RoleAssignmentListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RoleAssignmentListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RoleAssignmentListResultIterator) Response() RoleAssignmentListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RoleAssignmentListResultIterator) Value() RoleAssignment { - if !iter.page.NotDone() { - return RoleAssignment{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RoleAssignmentListResultIterator type. -func NewRoleAssignmentListResultIterator(page RoleAssignmentListResultPage) RoleAssignmentListResultIterator { - return RoleAssignmentListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (ralr RoleAssignmentListResult) IsEmpty() bool { - return ralr.Value == nil || len(*ralr.Value) == 0 -} - -// roleAssignmentListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (ralr RoleAssignmentListResult) roleAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { - if ralr.NextLink == nil || len(to.String(ralr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(ralr.NextLink))) -} - -// RoleAssignmentListResultPage contains a page of RoleAssignment values. -type RoleAssignmentListResultPage struct { - fn func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error) - ralr RoleAssignmentListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RoleAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.ralr) - if err != nil { - return err - } - page.ralr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RoleAssignmentListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RoleAssignmentListResultPage) NotDone() bool { - return !page.ralr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RoleAssignmentListResultPage) Response() RoleAssignmentListResult { - return page.ralr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RoleAssignmentListResultPage) Values() []RoleAssignment { - if page.ralr.IsEmpty() { - return nil - } - return *page.ralr.Value -} - -// Creates a new instance of the RoleAssignmentListResultPage type. -func NewRoleAssignmentListResultPage(getNextPage func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error)) RoleAssignmentListResultPage { - return RoleAssignmentListResultPage{fn: getNextPage} -} - -// RoleAssignmentProperties role assignment properties. -type RoleAssignmentProperties struct { - // RoleDefinitionID - The role definition ID used in the role assignment. - RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` - // PrincipalID - The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The delegation flag used for creating a role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleAssignmentPropertiesWithScope role assignment properties with scope. -type RoleAssignmentPropertiesWithScope struct { - // Scope - The role assignment scope. - Scope *string `json:"scope,omitempty"` - // RoleDefinitionID - The role definition ID. - RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` - // PrincipalID - The principal ID. - PrincipalID *string `json:"principalId,omitempty"` - // CanDelegate - The Delegation flag for the role assignment - CanDelegate *bool `json:"canDelegate,omitempty"` -} - -// RoleDefinition role definition. -type RoleDefinition struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The role definition ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The role definition name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The role definition type. - Type *string `json:"type,omitempty"` - // RoleDefinitionProperties - Role definition properties. - *RoleDefinitionProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RoleDefinition. -func (rd RoleDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rd.RoleDefinitionProperties != nil { - objectMap["properties"] = rd.RoleDefinitionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RoleDefinition struct. -func (rd *RoleDefinition) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rd.Type = &typeVar - } - case "properties": - if v != nil { - var roleDefinitionProperties RoleDefinitionProperties - err = json.Unmarshal(*v, &roleDefinitionProperties) - if err != nil { - return err - } - rd.RoleDefinitionProperties = &roleDefinitionProperties - } - } - } - - return nil -} - -// RoleDefinitionFilter role Definitions filter -type RoleDefinitionFilter struct { - // RoleName - Returns role definition with the specific name. - RoleName *string `json:"roleName,omitempty"` - // Type - Returns role definition with the specific type. - Type *string `json:"type,omitempty"` -} - -// RoleDefinitionListResult role definition list operation result. -type RoleDefinitionListResult struct { - autorest.Response `json:"-"` - // Value - Role definition list. - Value *[]RoleDefinition `json:"value,omitempty"` - // NextLink - The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// RoleDefinitionListResultIterator provides access to a complete listing of RoleDefinition values. -type RoleDefinitionListResultIterator struct { - i int - page RoleDefinitionListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RoleDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RoleDefinitionListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RoleDefinitionListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RoleDefinitionListResultIterator) Response() RoleDefinitionListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RoleDefinitionListResultIterator) Value() RoleDefinition { - if !iter.page.NotDone() { - return RoleDefinition{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RoleDefinitionListResultIterator type. -func NewRoleDefinitionListResultIterator(page RoleDefinitionListResultPage) RoleDefinitionListResultIterator { - return RoleDefinitionListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rdlr RoleDefinitionListResult) IsEmpty() bool { - return rdlr.Value == nil || len(*rdlr.Value) == 0 -} - -// roleDefinitionListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rdlr RoleDefinitionListResult) roleDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { - if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rdlr.NextLink))) -} - -// RoleDefinitionListResultPage contains a page of RoleDefinition values. -type RoleDefinitionListResultPage struct { - fn func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error) - rdlr RoleDefinitionListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RoleDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.rdlr) - if err != nil { - return err - } - page.rdlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RoleDefinitionListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RoleDefinitionListResultPage) NotDone() bool { - return !page.rdlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RoleDefinitionListResultPage) Response() RoleDefinitionListResult { - return page.rdlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RoleDefinitionListResultPage) Values() []RoleDefinition { - if page.rdlr.IsEmpty() { - return nil - } - return *page.rdlr.Value -} - -// Creates a new instance of the RoleDefinitionListResultPage type. -func NewRoleDefinitionListResultPage(getNextPage func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error)) RoleDefinitionListResultPage { - return RoleDefinitionListResultPage{fn: getNextPage} -} - -// RoleDefinitionProperties role definition properties. -type RoleDefinitionProperties struct { - // RoleName - The role name. - RoleName *string `json:"roleName,omitempty"` - // Description - The role definition description. - Description *string `json:"description,omitempty"` - // RoleType - The role type. - RoleType *string `json:"type,omitempty"` - // Permissions - Role definition permissions. - Permissions *[]Permission `json:"permissions,omitempty"` - // AssignableScopes - Role definition assignable scopes. - AssignableScopes *[]string `json:"assignableScopes,omitempty"` -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go deleted file mode 100644 index 896826b489..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/permissions.go +++ /dev/null @@ -1,274 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PermissionsClient is the client for the Permissions methods of the Authorization service. -type PermissionsClient struct { - BaseClient -} - -// NewPermissionsClient creates an instance of the PermissionsClient client. -func NewPermissionsClient(subscriptionID string) PermissionsClient { - return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPermissionsClientWithBaseURI creates an instance of the PermissionsClient client using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient { - return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListForResource gets all permissions the caller has for a resource. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource. -// resourceName - the name of the resource to get the permissions for. -func (client PermissionsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") - defer func() { - sc := -1 - if result.pgr.Response.Response != nil { - sc = result.pgr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceNextResults - req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.pgr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request") - return - } - - result.pgr, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure responding to request") - } - - return -} - -// ListForResourcePreparer prepares the ListForResource request. -func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceSender sends the ListForResource request. The method will close the -// http.Response Body if it receives an error. -func (client PermissionsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceResponder handles the response to the ListForResource request. The method always -// closes the http.Response Body. -func (client PermissionsClient) ListForResourceResponder(resp *http.Response) (result PermissionGetResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceNextResults retrieves the next set of results, if any. -func (client PermissionsClient) listForResourceNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { - req, err := lastResults.permissionGetResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. -func (client PermissionsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) - return -} - -// ListForResourceGroup gets all permissions the caller has for a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. -func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.pgr.Response.Response != nil { - sc = result.pgr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceGroupNextResults - req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.pgr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request") - return - } - - result.pgr, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListForResourceGroupPreparer prepares the ListForResourceGroup request. -func (client PermissionsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client PermissionsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always -// closes the http.Response Body. -func (client PermissionsClient) ListForResourceGroupResponder(resp *http.Response) (result PermissionGetResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceGroupNextResults retrieves the next set of results, if any. -func (client PermissionsClient) listForResourceGroupNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) { - req, err := lastResults.permissionGetResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client PermissionsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PermissionGetResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResourceGroup(ctx, resourceGroupName) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go deleted file mode 100644 index 22943f68e3..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/provideroperationsmetadata.go +++ /dev/null @@ -1,235 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// ProviderOperationsMetadataClient is the client for the ProviderOperationsMetadata methods of the Authorization -// service. -type ProviderOperationsMetadataClient struct { - BaseClient -} - -// NewProviderOperationsMetadataClient creates an instance of the ProviderOperationsMetadataClient client. -func NewProviderOperationsMetadataClient(subscriptionID string) ProviderOperationsMetadataClient { - return NewProviderOperationsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewProviderOperationsMetadataClientWithBaseURI creates an instance of the ProviderOperationsMetadataClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscriptionID string) ProviderOperationsMetadataClient { - return ProviderOperationsMetadataClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets provider operations metadata for the specified resource provider. -// Parameters: -// resourceProviderNamespace - the namespace of the resource provider. -// expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result ProviderOperationsMetadata, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceProviderNamespace, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } else { - queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ProviderOperationsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) (result ProviderOperationsMetadata, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets provider operations metadata for all resource providers. -// Parameters: -// expand - specifies whether to expand the values. -func (client ProviderOperationsMetadataClient) List(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List") - defer func() { - sc := -1 - if result.pomlr.Response.Response != nil { - sc = result.pomlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, expand) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.pomlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request") - return - } - - result.pomlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(expand) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } else { - queryParameters["$expand"] = autorest.Encode("query", "resourceTypes") - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Authorization/providerOperations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ProviderOperationsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ProviderOperationsMetadataClient) ListResponder(resp *http.Response) (result ProviderOperationsMetadataListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ProviderOperationsMetadataClient) listNextResults(ctx context.Context, lastResults ProviderOperationsMetadataListResult) (result ProviderOperationsMetadataListResult, err error) { - req, err := lastResults.providerOperationsMetadataListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, expand) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go deleted file mode 100644 index bcf2a43d55..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roleassignments.go +++ /dev/null @@ -1,992 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RoleAssignmentsClient is the client for the RoleAssignments methods of the Authorization service. -type RoleAssignmentsClient struct { - BaseClient -} - -// NewRoleAssignmentsClient creates an instance of the RoleAssignmentsClient client. -func NewRoleAssignmentsClient(subscriptionID string) RoleAssignmentsClient { - return NewRoleAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRoleAssignmentsClientWithBaseURI creates an instance of the RoleAssignmentsClient client using a custom endpoint. -// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentsClient { - return RoleAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Create creates a role assignment. -// Parameters: -// scope - the scope of the role assignment to create. The scope can be any REST resource instance. For -// example, use '/subscriptions/{subscription-id}/' for a subscription, -// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and -// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' -// for a resource. -// roleAssignmentName - the name of the role assignment to create. It can be any valid GUID. -// parameters - parameters for the role assignment. -func (client RoleAssignmentsClient) Create(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Create") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("authorization.RoleAssignmentsClient", "Create", err.Error()) - } - - req, err := client.CreatePreparer(ctx, scope, roleAssignmentName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client RoleAssignmentsClient) CreatePreparer(ctx context.Context, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) CreateResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateByID creates a role assignment by ID. -// Parameters: -// roleID - the ID of the role assignment to create. -// parameters - parameters for the role assignment. -func (client RoleAssignmentsClient) CreateByID(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.CreateByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.RoleAssignmentProperties.RoleDefinitionID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.RoleAssignmentProperties.PrincipalID", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("authorization.RoleAssignmentsClient", "CreateByID", err.Error()) - } - - req, err := client.CreateByIDPreparer(ctx, roleID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", nil, "Failure preparing request") - return - } - - resp, err := client.CreateByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure sending request") - return - } - - result, err = client.CreateByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure responding to request") - } - - return -} - -// CreateByIDPreparer prepares the CreateByID request. -func (client RoleAssignmentsClient) CreateByIDPreparer(ctx context.Context, roleID string, parameters RoleAssignmentCreateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateByIDSender sends the CreateByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) CreateByIDSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateByIDResponder handles the response to the CreateByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) CreateByIDResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a role assignment. -// Parameters: -// scope - the scope of the role assignment to delete. -// roleAssignmentName - the name of the role assignment to delete. -func (client RoleAssignmentsClient) Delete(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Delete") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, scope, roleAssignmentName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RoleAssignmentsClient) DeletePreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteByID deletes a role assignment. -// Parameters: -// roleID - the ID of the role assignment to delete. -func (client RoleAssignmentsClient) DeleteByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeleteByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure sending request") - return - } - - result, err = client.DeleteByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure responding to request") - } - - return -} - -// DeleteByIDPreparer prepares the DeleteByID request. -func (client RoleAssignmentsClient) DeleteByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteByIDSender sends the DeleteByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteByIDResponder handles the response to the DeleteByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get the specified role assignment. -// Parameters: -// scope - the scope of the role assignment. -// roleAssignmentName - the name of the role assignment to get. -func (client RoleAssignmentsClient) Get(ctx context.Context, scope string, roleAssignmentName string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, scope, roleAssignmentName) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client RoleAssignmentsClient) GetPreparer(ctx context.Context, scope string, roleAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleAssignmentName": autorest.Encode("path", roleAssignmentName), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) GetResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID gets a role assignment by ID. -// Parameters: -// roleID - the ID of the role assignment to get. -func (client RoleAssignmentsClient) GetByID(ctx context.Context, roleID string) (result RoleAssignment, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", nil, "Failure preparing request") - return - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure sending request") - return - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client RoleAssignmentsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) GetByIDResponder(resp *http.Response) (result RoleAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets all role assignments for the subscription. -// Parameters: -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) List(ctx context.Context, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.List") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client RoleAssignmentsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListComplete(ctx context.Context, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, filter) - return -} - -// ListForResource gets role assignments for a resource. -// Parameters: -// resourceGroupName - the name of the resource group. -// resourceProviderNamespace - the namespace of the resource provider. -// parentResourcePath - the parent resource identity. -// resourceType - the resource type of the resource. -// resourceName - the name of the resource to get role assignments for. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceNextResults - req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure responding to request") - } - - return -} - -// ListForResourcePreparer prepares the ListForResource request. -func (client RoleAssignmentsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": parentResourcePath, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), - "resourceType": resourceType, - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceSender sends the ListForResource request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceResponder handles the response to the ListForResource request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForResourceResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForResourceNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResource") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - return -} - -// ListForResourceGroup gets role assignments for a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForResourceGroupNextResults - req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListForResourceGroupPreparer prepares the ListForResourceGroup request. -func (client RoleAssignmentsClient) ListForResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForResourceGroupNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForResourceGroupNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForResourceGroup(ctx, resourceGroupName, filter) - return -} - -// ListForScope gets role assignments for a scope. -// Parameters: -// scope - the scope of the role assignments. -// filter - the filter to apply on the operation. Use $filter=atScope() to return all role assignments at or -// above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope -// for the specified principal. -func (client RoleAssignmentsClient) ListForScope(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") - defer func() { - sc := -1 - if result.ralr.Response.Response != nil { - sc = result.ralr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listForScopeNextResults - req, err := client.ListForScopePreparer(ctx, scope, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", nil, "Failure preparing request") - return - } - - resp, err := client.ListForScopeSender(req) - if err != nil { - result.ralr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure sending request") - return - } - - result.ralr, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure responding to request") - } - - return -} - -// ListForScopePreparer prepares the ListForScope request. -func (client RoleAssignmentsClient) ListForScopePreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListForScopeSender sends the ListForScope request. The method will close the -// http.Response Body if it receives an error. -func (client RoleAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListForScopeResponder handles the response to the ListForScope request. The method always -// closes the http.Response Body. -func (client RoleAssignmentsClient) ListForScopeResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listForScopeNextResults retrieves the next set of results, if any. -func (client RoleAssignmentsClient) listForScopeNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { - req, err := lastResults.roleAssignmentListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListForScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure sending next results request") - } - result, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "listForScopeNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListForScopeComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleAssignmentsClient) ListForScopeComplete(ctx context.Context, scope string, filter string) (result RoleAssignmentListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListForScope") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListForScope(ctx, scope, filter) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go deleted file mode 100644 index 124e84af07..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/roledefinitions.go +++ /dev/null @@ -1,465 +0,0 @@ -package authorization - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RoleDefinitionsClient is the client for the RoleDefinitions methods of the Authorization service. -type RoleDefinitionsClient struct { - BaseClient -} - -// NewRoleDefinitionsClient creates an instance of the RoleDefinitionsClient client. -func NewRoleDefinitionsClient(subscriptionID string) RoleDefinitionsClient { - return NewRoleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRoleDefinitionsClientWithBaseURI creates an instance of the RoleDefinitionsClient client using a custom endpoint. -// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) RoleDefinitionsClient { - return RoleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates a role definition. -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition. -// roleDefinition - the values for the role definition. -func (client RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, scope, roleDefinitionID, roleDefinition) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RoleDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - roleDefinition.ID = nil - roleDefinition.Name = nil - roleDefinition.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithJSON(roleDefinition), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result RoleDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a role definition. -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition to delete. -func (client RoleDefinitionsClient) Delete(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Delete") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, scope, roleDefinitionID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RoleDefinitionsClient) DeletePreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get role definition by name (GUID). -// Parameters: -// scope - the scope of the role definition. -// roleDefinitionID - the ID of the role definition. -func (client RoleDefinitionsClient) Get(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, scope, roleDefinitionID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client RoleDefinitionsClient) GetPreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID gets a role definition by ID. -// Parameters: -// roleID - the fully qualified role definition ID. Use the format, -// /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription -// level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant -// level role definitions. -func (client RoleDefinitionsClient) GetByID(ctx context.Context, roleID string) (result RoleDefinition, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByID") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByIDPreparer(ctx, roleID) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request") - return - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request") - return - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client RoleDefinitionsClient) GetByIDPreparer(ctx context.Context, roleID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "roleId": roleID, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{roleId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) GetByIDResponder(resp *http.Response) (result RoleDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List get all role definitions that are applicable at scope and above. -// Parameters: -// scope - the scope of the role definition. -// filter - the filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as -// well. -func (client RoleDefinitionsClient) List(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List") - defer func() { - sc := -1 - if result.rdlr.Response.Response != nil { - sc = result.rdlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, scope, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.rdlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request") - return - } - - result.rdlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client RoleDefinitionsClient) ListPreparer(ctx context.Context, scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": scope, - } - - const APIVersion = "2018-01-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RoleDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RoleDefinitionsClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client RoleDefinitionsClient) listNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { - req, err := lastResults.roleDefinitionListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client RoleDefinitionsClient) ListComplete(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, scope, filter) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go deleted file mode 100644 index f0a7e474c8..0000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization/version.go +++ /dev/null @@ -1,30 +0,0 @@ -package authorization - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " authorization/2018-01-01-preview" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 53dd223caf..31f7cfe76a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -9,7 +9,6 @@ github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-10-01/network github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network -github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/operationalinsights