private void CreateAfdRoute() { try { List <ResourceReference> afdCustomDomainIdList = new List <ResourceReference>(); foreach (string afdCustomDomain in this.CustomDomainId) { afdCustomDomainIdList.Add(new ResourceReference(afdCustomDomain)); } Route afdRoute = new Route { OriginGroup = new ResourceReference(this.OriginGroupId), CustomDomains = afdCustomDomainIdList }; PSAfdRoute psAfdRoute = this.CdnManagementClient.Routes.Create(this.ResourceGroupName, this.ProfileName, this.EndpointName, this.RouteName, afdRoute).ToPSAfdRoute(); WriteObject(psAfdRoute); } catch (AfdErrorResponseException errorResponse) { throw new PSArgumentException(errorResponse.Response.Content); } }
private void ResourceIdParameterSetCmdlet() { ResourceIdentifier parsedAfdRouteResourceId = new ResourceIdentifier(this.ResourceId); this.RouteName = parsedAfdRouteResourceId.ResourceName; this.EndpointName = parsedAfdRouteResourceId.GetResourceName("afdendpoints"); this.ProfileName = parsedAfdRouteResourceId.GetResourceName("profiles"); this.ResourceGroupName = parsedAfdRouteResourceId.ResourceGroupName; PSAfdRoute psAfdRoute = this.CdnManagementClient.Routes.Get(this.ResourceGroupName, this.ProfileName, this.EndpointName, this.RouteName).ToPSAfdRoute(); WriteObject(psAfdRoute); }
private void FieldsParameterSetCmdlet() { if (this.MyInvocation.BoundParameters.ContainsKey("RouteName")) { PSAfdRoute psAfdRoute = this.CdnManagementClient.Routes.Get(this.ResourceGroupName, this.ProfileName, this.EndpointName, this.RouteName).ToPSAfdRoute(); WriteObject(psAfdRoute); } else { List <PSAfdRoute> psAfdRouteList = this.CdnManagementClient.Routes.ListByEndpoint(this.ResourceGroupName, this.ProfileName, this.EndpointName) .Select(afdRoute => afdRoute.ToPSAfdRoute()) .ToList(); WriteObject(psAfdRouteList); } }
private void UpdateAfdRoute() { try { PSAfdRoute currentPsAfdRoute = this.CdnManagementClient.Routes.Get(this.ResourceGroupName, this.ProfileName, this.EndpointName, this.RouteName).ToPSAfdRoute(); RouteUpdateParameters afdRouteUpdateParameters = new RouteUpdateParameters(); if (ParameterSetName == FieldsParameterSet) { afdRouteUpdateParameters = this.CreateAfdRouteUpdateByFields(currentPsAfdRoute); } PSAfdRoute updatedPsAfdRoute = this.CdnManagementClient.Routes.Update(this.ResourceGroupName, this.ProfileName, this.EndpointName, this.RouteName, afdRouteUpdateParameters).ToPSAfdRoute(); WriteObject(updatedPsAfdRoute); } catch (AfdErrorResponseException errorResponse) { throw new PSArgumentException(errorResponse.Response.Content); } }
private RouteUpdateParameters CreateAfdRouteUpdateByFields(PSAfdRoute currentPsAfdRoute) { bool isCustomDomainId = this.MyInvocation.BoundParameters.ContainsKey("CustomDomainId"); bool isSupportedProtocols = this.MyInvocation.BoundParameters.ContainsKey("SupportedProtocol"); bool isHttpsRedirect = this.MyInvocation.BoundParameters.ContainsKey("HttpsRedirect"); bool isOriginGroupId = this.MyInvocation.BoundParameters.ContainsKey("OriginGroupId"); bool isOriginPath = this.MyInvocation.BoundParameters.ContainsKey("OriginPath"); bool isForwardingProtocol = this.MyInvocation.BoundParameters.ContainsKey("ForwardingProtocol"); bool isQueryStringCachingBehavior = this.MyInvocation.BoundParameters.ContainsKey("QueryStringCachingBehavior"); bool isRuleSetIds = this.MyInvocation.BoundParameters.ContainsKey("RuleSetId"); RouteUpdateParameters afdRouteUpdateParameters = new RouteUpdateParameters { CustomDomains = currentPsAfdRoute.CustomDomainIds, SupportedProtocols = currentPsAfdRoute.SupportedProtocols, HttpsRedirect = currentPsAfdRoute.HttpsRedirect, OriginGroup = new ResourceReference(currentPsAfdRoute.OriginGroupId), OriginPath = currentPsAfdRoute.OriginPath, ForwardingProtocol = currentPsAfdRoute.ForwardingProtocol, RuleSets = currentPsAfdRoute.RuleSetIds, QueryStringCachingBehavior = AfdUtilities.CreateQueryStringCachingBehavior(currentPsAfdRoute.QueryStringCachingBehavior) }; if (isCustomDomainId) { foreach (string customDomainId in this.CustomDomainId) { afdRouteUpdateParameters.CustomDomains.Add(new ResourceReference(customDomainId)); } } if (isSupportedProtocols) { afdRouteUpdateParameters.SupportedProtocols = this.SupportedProtocol; } if (isHttpsRedirect) { afdRouteUpdateParameters.HttpsRedirect = AfdUtilities.CreateHttpsRedirect(this.HttpsRedirect); } if (isOriginGroupId) { afdRouteUpdateParameters.OriginGroup = new ResourceReference(this.OriginGroupId); } if (isOriginPath) { afdRouteUpdateParameters.OriginPath = this.OriginPath; } if (isForwardingProtocol) { afdRouteUpdateParameters.ForwardingProtocol = AfdUtilities.CreateForwardingProtocol(this.ForwardingProtocol); } if (isQueryStringCachingBehavior) { afdRouteUpdateParameters.QueryStringCachingBehavior = AfdUtilities.CreateQueryStringCachingBehavior(this.QueryStringCachingBehavior); } if (isRuleSetIds) { foreach (string ruleSetId in this.RuleSetId) { afdRouteUpdateParameters.RuleSets.Add(new ResourceReference(ruleSetId)); } } return(afdRouteUpdateParameters); }