Ejemplo n.º 1
0
        public static EventMetadata GetEventMetadata(string resourceUriString, string hostname, string accessToken)
        {
            EventMetadata metadata = null;

            string             url     = $"https://{hostname}/api/resource/GetPISystemMetadata?ResourceUriString={resourceUriString}";
            RestRequestBuilder builder = new RestRequestBuilder("GET", url, RestConstants.ContentType.Json, true, accessToken);
            RestRequest        request = new RestRequest(builder);

            try
            {
                metadata = request.Get <EventMetadata>();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to get event metadata");
                Console.WriteLine(ex.Message);
            }

            if (metadata == null || string.IsNullOrEmpty(metadata.ResourceUriString))
            {
                return(null);
            }
            else
            {
                return(metadata);
            }
        }
Ejemplo n.º 2
0
        public static void AddEventMetadata(EventMetadata metadata, string hostname, string accessToken)
        {
            string             url     = String.Format($"https://{hostname}/api/resource/UpsertPiSystemMetadata");
            RestRequestBuilder builder = new RestRequestBuilder("PUT", url, RestConstants.ContentType.Json, false, accessToken);
            RestRequest        request = new RestRequest(builder);

            request.Put <EventMetadata>(metadata);
        }
Ejemplo n.º 3
0
        public static void AddCaplPolicy(AuthorizationPolicy policy, string hostname, string accessToken)
        {
            if (HasCaplPolicy(policy.PolicyId.ToString(), hostname, accessToken))
            {
                return;
            }

            string             url     = String.Format($"https://{hostname}/api/accesscontrol/upsertaccesscontrolpolicy");
            RestRequestBuilder builder = new RestRequestBuilder("PUT", url, RestConstants.ContentType.Xml, false, accessToken);
            RestRequest        request = new RestRequest(builder);

            request.Put <AuthorizationPolicy>(policy);
        }
Ejemplo n.º 4
0
        public static bool HasCaplPolicy(string policyId, string hostname, string accessToken)
        {
            string             url     = String.Format($"https://{hostname}/api/accesscontrol/getaccesscontrolpolicy?policyuristring={policyId.ToLowerInvariant()}");
            RestRequestBuilder builder = new RestRequestBuilder("GET", url, RestConstants.ContentType.Xml, true, accessToken);
            RestRequest        request = new RestRequest(builder);

            try
            {
                AuthorizationPolicy policy = request.Get <AuthorizationPolicy>();
                return(policy != null);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 public RestRequest(RestRequestBuilder builder)
 {
     requestBuilder = builder;
 }
Ejemplo n.º 6
0
 public RestRequest(RestRequestBuilder builder)
 {
     this.requestBuilder = builder;
 }