internal Certificate( BatchClient parentBatchClient, Models.Certificate protocolObject, IEnumerable <BatchClientBehavior> baseBehaviors) { this.parentBatchClient = parentBatchClient; InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, baseBehaviors); this.propertyContainer = new PropertyContainer(protocolObject); }
/// <summary> /// Builds a CertificateGetResponse object /// </summary> public static ProxyModels.CertificateGetResponse CreateCertificateGetResponse(string thumbprint) { ProxyModels.CertificateGetResponse response = new ProxyModels.CertificateGetResponse(); response.StatusCode = HttpStatusCode.OK; ProxyModels.Certificate cert = new ProxyModels.Certificate(); cert.Thumbprint = thumbprint; response.Certificate = cert; return(response); }
/// <summary> /// Builds a CertificateGetResponse object /// </summary> public static AzureOperationResponse <ProxyModels.Certificate, ProxyModels.CertificateGetHeaders> CreateCertificateGetResponse(string thumbprint) { var response = new AzureOperationResponse <ProxyModels.Certificate, ProxyModels.CertificateGetHeaders>(); response.Response = new HttpResponseMessage(HttpStatusCode.OK); ProxyModels.Certificate cert = new ProxyModels.Certificate(); cert.Thumbprint = thumbprint; response.Body = cert; return(response); }
public PropertyContainer(Models.Certificate protocolObject) : base(BindingState.Bound) { this.CertificateFormatProperty = this.CreatePropertyAccessor <Common.CertificateFormat?>( nameof(CertificateFormat), BindingAccess.None); this.DataProperty = this.CreatePropertyAccessor <string>( nameof(Data), BindingAccess.None); this.DeleteCertificateErrorProperty = this.CreatePropertyAccessor( UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.DeleteCertificateError, o => new DeleteCertificateError(o).Freeze()), nameof(DeleteCertificateError), BindingAccess.Read); this.PasswordProperty = this.CreatePropertyAccessor <string>( nameof(Password), BindingAccess.None); this.PreviousStateProperty = this.CreatePropertyAccessor( UtilitiesInternal.MapNullableEnum <Models.CertificateState, Common.CertificateState>(protocolObject.PreviousState), nameof(PreviousState), BindingAccess.Read); this.PreviousStateTransitionTimeProperty = this.CreatePropertyAccessor( protocolObject.PreviousStateTransitionTime, nameof(PreviousStateTransitionTime), BindingAccess.Read); this.PublicDataProperty = this.CreatePropertyAccessor( protocolObject.PublicData, nameof(PublicData), BindingAccess.Read); this.StateProperty = this.CreatePropertyAccessor( UtilitiesInternal.MapNullableEnum <Models.CertificateState, Common.CertificateState>(protocolObject.State), nameof(State), BindingAccess.Read); this.StateTransitionTimeProperty = this.CreatePropertyAccessor( protocolObject.StateTransitionTime, nameof(StateTransitionTime), BindingAccess.Read); this.ThumbprintProperty = this.CreatePropertyAccessor( protocolObject.Thumbprint, nameof(Thumbprint), BindingAccess.Read); this.ThumbprintAlgorithmProperty = this.CreatePropertyAccessor( protocolObject.ThumbprintAlgorithm, nameof(ThumbprintAlgorithm), BindingAccess.Read); this.UrlProperty = this.CreatePropertyAccessor( protocolObject.Url, nameof(Url), BindingAccess.Read); }
public PropertyContainer(Models.Certificate protocolObject) : base(BindingState.Bound) { this.CertificateFormatProperty = this.CreatePropertyAccessor <Common.CertificateFormat?>( "CertificateFormat", BindingAccess.None); this.DataProperty = this.CreatePropertyAccessor <string>( "Data", BindingAccess.None); this.DeleteCertificateErrorProperty = this.CreatePropertyAccessor( UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.DeleteCertificateError, o => new DeleteCertificateError(o).Freeze()), "DeleteCertificateError", BindingAccess.Read); this.PasswordProperty = this.CreatePropertyAccessor <string>( "Password", BindingAccess.None); this.PreviousStateProperty = this.CreatePropertyAccessor( UtilitiesInternal.MapNullableEnum <Models.CertificateState, Common.CertificateState>(protocolObject.PreviousState), "PreviousState", BindingAccess.Read); this.PreviousStateTransitionTimeProperty = this.CreatePropertyAccessor( protocolObject.PreviousStateTransitionTime, "PreviousStateTransitionTime", BindingAccess.Read); this.PublicDataProperty = this.CreatePropertyAccessor( protocolObject.PublicData, "PublicData", BindingAccess.Read); this.StateProperty = this.CreatePropertyAccessor( UtilitiesInternal.MapNullableEnum <Models.CertificateState, Common.CertificateState>(protocolObject.State), "State", BindingAccess.Read); this.StateTransitionTimeProperty = this.CreatePropertyAccessor( protocolObject.StateTransitionTime, "StateTransitionTime", BindingAccess.Read); this.ThumbprintProperty = this.CreatePropertyAccessor( protocolObject.Thumbprint, "Thumbprint", BindingAccess.Read); this.ThumbprintAlgorithmProperty = this.CreatePropertyAccessor( protocolObject.ThumbprintAlgorithm, "ThumbprintAlgorithm", BindingAccess.Read); this.UrlProperty = this.CreatePropertyAccessor( protocolObject.Url, "Url", BindingAccess.Read); }
/// <summary> /// Refreshes the current <see cref="Certificate"/>. /// </summary> /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Thumbprint"/> or <see cref="ThumbprintAlgorithm"/> property is specified, refresh will fail.</param> /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param> /// <returns>A <see cref="Task"/> representing the asynchronous refresh operation.</returns> public async Task RefreshAsync(DetailLevel detailLevel = null, IEnumerable <BatchClientBehavior> additionalBehaviors = null, CancellationToken cancellationToken = default(CancellationToken)) { // set up behavior manager BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); // start operation Task <AzureOperationResponse <Models.Certificate, Models.CertificateGetHeaders> > asyncTask = this.parentBatchClient.ProtocolLayer.GetCertificate(this.ThumbprintAlgorithm, this.Thumbprint, bhMgr, cancellationToken); AzureOperationResponse <Models.Certificate, Models.CertificateGetHeaders> response = await asyncTask.ConfigureAwait(continueOnCapturedContext : false); // extract the refreshed protocol object Models.Certificate refreshedProtoCert = response.Body; // swap in the new protocol object this.propertyContainer = new PropertyContainer(refreshedProtoCert); }
/// <summary> /// Builds a CertificateListResponse object /// </summary> public static ProxyModels.CertificateListResponse CreateCertificateListResponse(IEnumerable <string> certThumbprints) { ProxyModels.CertificateListResponse response = new ProxyModels.CertificateListResponse(); response.StatusCode = HttpStatusCode.OK; List <ProxyModels.Certificate> certs = new List <ProxyModels.Certificate>(); foreach (string t in certThumbprints) { ProxyModels.Certificate cert = new ProxyModels.Certificate(); cert.Thumbprint = t; certs.Add(cert); } response.Certificates = certs; return(response); }
/// <summary> /// Builds a CertificateListResponse object /// </summary> public static AzureOperationResponse <IPage <ProxyModels.Certificate>, ProxyModels.CertificateListHeaders> CreateCertificateListResponse(IEnumerable <string> certThumbprints) { var response = new AzureOperationResponse <IPage <ProxyModels.Certificate>, ProxyModels.CertificateListHeaders>(); response.Response = new HttpResponseMessage(HttpStatusCode.OK); List <ProxyModels.Certificate> certs = new List <ProxyModels.Certificate>(); foreach (string t in certThumbprints) { ProxyModels.Certificate cert = new ProxyModels.Certificate(); cert.Thumbprint = t; certs.Add(cert); } response.Body = new MockPagedEnumerable <ProxyModels.Certificate>(certs); return(response); }
/// <summary> /// Gets the specified <see cref="Certificate"/>. /// </summary> /// <param name="thumbprintAlgorithm">The algorithm used to derive the <paramref name="thumbprint"/> parameter. This must be sha1.</param> /// <param name="thumbprint">The thumbprint of the certificate to get.</param> /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved from the service.</param> /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/> and <paramref name="detailLevel"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param> /// <returns>A <see cref="Certificate"/> containing information about the specified certificate in the Azure Batch account.</returns> /// <remarks>The get certificate operation runs asynchronously.</remarks> public async Task <Certificate> GetCertificateAsync( string thumbprintAlgorithm, string thumbprint, DetailLevel detailLevel = null, IEnumerable <BatchClientBehavior> additionalBehaviors = null, CancellationToken cancellationToken = default(CancellationToken)) { // set up behavior manager BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); // start operation Task <AzureOperationResponse <Models.Certificate, Models.CertificateGetHeaders> > asyncTask = _parentBatchClient.ProtocolLayer.GetCertificate(thumbprintAlgorithm, thumbprint, bhMgr, cancellationToken); // wait for operation to complete var response = await asyncTask.ConfigureAwait(continueOnCapturedContext : false); // extract results Models.Certificate protoCert = response.Body; // wrap protocol object Certificate omCert = new Certificate(this.ParentBatchClient, protoCert, this.CustomBehaviors); return(omCert); }
public static IEnumerable <Protocol.RequestInterceptor> CreateGetCertificateRequestInterceptor(Protocol.Models.Certificate certificateToReturn) { return(CreateGetRequestInterceptor <Protocol.Models.CertificateGetOptions, Protocol.Models.Certificate, Protocol.Models.CertificateGetHeaders>(certificateToReturn)); }