Example #1
0
        /// <inheritdoc/>
        public DnsRecord UpdateDnsRecord(string domainId, string recordId, string name = null, string type = null, string data = null, int?priority = null, int?ttl = null, string description = null, string gslbRegion = null, int?gslbWeight = null, int?gslbCheck = null, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (recordId == null)
            {
                throw new ArgumentNullException("recordId");
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentException("recordId cannot be empty");
            }
            if (ttl.HasValue && ttl < 3600)
            {
                throw new ArgumentException("ttl must be 3600 and more");
            }
            if (priority.HasValue && (priority < 0 || priority > 65535))
            {
                throw new ArgumentOutOfRangeException("priority must be 0~65535");
            }
            if (gslbWeight.HasValue && (gslbWeight < 0 || gslbWeight > 255))
            {
                throw new ArgumentOutOfRangeException("gslbWeight must be 0~255");
            }
            if (gslbCheck.HasValue && (gslbCheck < 0 || gslbCheck > 65535))
            {
                throw new ArgumentOutOfRangeException("gslbCheck must be 0~65535");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}/records/{2}", GetServiceEndpoint(identity, region), domainId, recordId));

            var request = new CreateDnsRecordRequest(name, type, priority, ttl, data, description, gslbRegion, gslbWeight, gslbCheck);

            var response = ExecuteRESTRequest <DnsRecord>(identity, urlPath, HttpMethod.PUT, request);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(response.Data);
        }
Example #2
0
        public async Task HandleAsync(TeamCreatedEvent @event, CancellationToken cancellationToken)
        {
            if (_hostingEnvironment.IsDevelopment())
            {
                return;
            }

            var request = new CreateDnsRecordRequest
                          (
                _cloudflareOptions.ZoneId,
                $"{@event.TeamId}.stubbl.in",
                DnsRecordType.Cname,
                "stubblapi.azurewebsites.net"
                          );

            var response = await _cloudflareApi.DnsRecords.CreateAsync(request, cancellationToken);
        }