|
| 1 | +//go:generate mockgen -destination=./mocks/cdn.go -package=mocks . ProfilesClient,EndpointsClient,CustomDomainsClient,OriginsClient,OriginGroupsClient,RoutesClient,RuleSetsClient,RulesClient,SecurityPoliciesClient |
| 2 | +package services |
| 3 | + |
| 4 | +import ( |
| 5 | + "context" |
| 6 | + |
| 7 | + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2020-09-01/cdn" |
| 8 | + "github.com/Azure/go-autorest/autorest" |
| 9 | +) |
| 10 | + |
| 11 | +type ProfilesClient interface { |
| 12 | + List(ctx context.Context) (result cdn.ProfileListResultPage, err error) |
| 13 | +} |
| 14 | + |
| 15 | +type EndpointsClient interface { |
| 16 | + ListByProfile(ctx context.Context, resourceGroupName string, profileName string) (result cdn.EndpointListResultPage, err error) |
| 17 | +} |
| 18 | + |
| 19 | +type CustomDomainsClient interface { |
| 20 | + ListByEndpoint(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result cdn.CustomDomainListResultPage, err error) |
| 21 | +} |
| 22 | + |
| 23 | +type OriginsClient interface { |
| 24 | + ListByEndpoint(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result cdn.OriginListResultPage, err error) |
| 25 | +} |
| 26 | + |
| 27 | +type OriginGroupsClient interface { |
| 28 | + ListByEndpoint(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result cdn.OriginGroupListResultPage, err error) |
| 29 | +} |
| 30 | + |
| 31 | +type RoutesClient interface { |
| 32 | + ListByEndpoint(ctx context.Context, resourceGroupName string, profileName string, endpointName string) (result cdn.RouteListResultPage, err error) |
| 33 | +} |
| 34 | + |
| 35 | +type RuleSetsClient interface { |
| 36 | + ListByProfile(ctx context.Context, resourceGroupName string, profileName string) (result cdn.RuleSetListResultPage, err error) |
| 37 | +} |
| 38 | + |
| 39 | +type RulesClient interface { |
| 40 | + ListByRuleSet(ctx context.Context, resourceGroupName string, profileName string, ruleSetName string) (result cdn.RuleListResultPage, err error) |
| 41 | +} |
| 42 | + |
| 43 | +type SecurityPoliciesClient interface { |
| 44 | + ListByProfile(ctx context.Context, resourceGroupName string, profileName string) (result cdn.SecurityPolicyListResultPage, err error) |
| 45 | +} |
| 46 | + |
| 47 | +type CDNClient struct { |
| 48 | + Profiles ProfilesClient |
| 49 | + Endpoints EndpointsClient |
| 50 | + CustomDomains CustomDomainsClient |
| 51 | + Origins OriginsClient |
| 52 | + OriginGroups OriginGroupsClient |
| 53 | + Routes RoutesClient |
| 54 | + RuleSets RuleSetsClient |
| 55 | + Rules RulesClient |
| 56 | + SecurityPolicies SecurityPoliciesClient |
| 57 | +} |
| 58 | + |
| 59 | +func NewCDNClient(subscriptionId string, auth autorest.Authorizer) CDNClient { |
| 60 | + p := cdn.NewProfilesClient(subscriptionId) |
| 61 | + p.Authorizer = auth |
| 62 | + |
| 63 | + e := cdn.NewEndpointsClient(subscriptionId) |
| 64 | + e.Authorizer = auth |
| 65 | + |
| 66 | + cd := cdn.NewCustomDomainsClient(subscriptionId) |
| 67 | + cd.Authorizer = auth |
| 68 | + |
| 69 | + o := cdn.NewOriginsClient(subscriptionId) |
| 70 | + o.Authorizer = auth |
| 71 | + |
| 72 | + og := cdn.NewOriginGroupsClient(subscriptionId) |
| 73 | + og.Authorizer = auth |
| 74 | + |
| 75 | + r := cdn.NewRoutesClient(subscriptionId) |
| 76 | + r.Authorizer = auth |
| 77 | + |
| 78 | + rs := cdn.NewRuleSetsClient(subscriptionId) |
| 79 | + rs.Authorizer = auth |
| 80 | + |
| 81 | + rul := cdn.NewRulesClient(subscriptionId) |
| 82 | + rul.Authorizer = auth |
| 83 | + |
| 84 | + sp := cdn.NewSecurityPoliciesClient(subscriptionId) |
| 85 | + sp.Authorizer = auth |
| 86 | + return CDNClient{ |
| 87 | + Profiles: p, |
| 88 | + Endpoints: e, |
| 89 | + CustomDomains: cd, |
| 90 | + Origins: o, |
| 91 | + Routes: r, |
| 92 | + OriginGroups: og, |
| 93 | + RuleSets: rs, |
| 94 | + Rules: rul, |
| 95 | + SecurityPolicies: sp, |
| 96 | + } |
| 97 | +} |
0 commit comments