How can I check if telegram session is currently in use? - telethon

Is there a way to check if session is in use?
I want to make sure that I do not use a session if it is already in use on a different IP address.
I am currently using telethon-session-sqlalchemy

I think you can use this to get active session:
GetAuthorizationsRequest()

You can make some request, if session down, you will get exception

Related

Jira API bulk create - create all or none

I want to create multiple issues at once using /rest/api/2/issue/bulk endpoint.
However, I want it to fail if ANY of the tickets fail. Right now it creates tickets that are correct, but my preferred way is to block it from adding any ticket if at least one fails.
Is there a way to do it? Thanks!
If the response from the server is an error message (IE the request failed) why not use that as the point to stop processing any more requests?

Do I need to call startRefresh7 on a newly item just added with startRefreshItemOnAddition=true

or can I skip the startRefresh7, which will save good amount of time as network traffic is time consuming.
And if yes, just to be complete, this means that I can go straight to isItemRefreshing to check if/when the refresh finishes.
Is the above possible?
Thanks.
This is important to handle MFA. So in additemForContentService1 API you need to pass the "startRefreshItemOnAddition" as false. Then you need to call the startRefresh7 with correct refreshMode depending on what type of site you are trying to link.
If you don't want to implement MFA then you can just pass "startRefreshItemOnAddition" as true and then continue with isItemRefreshing.
But I will strongly recommend implementation of MFA as well.

Closing JiraClient properly

I am using this plugin to help my web-app communicate with Atlassian JIRA.
So my question -> Is there a proper way to close net.rcarz.jiraclient.JiraClient instance when I'm done with it?
I'm guessing leaving it be and creating a client = new JiraClient(uri,creds) when next user logs in is not a good idea...
JiraClient doesn't keeps a connection open, it just uses the supplied credentials for each request. You don't have to close it. As far as I can tell, you a free to use multiple JiraClient concurrently.

Check if one has already logged into Bloomberg (via API)

Is there a way to test if current user has been authenticated to BBG? I have my c# program which uses BBG API, and want to check if the user logged in the service before, either via API calls or the BBG Terminal. This check can then be used to distinguish whether the user's network is unavailable or simply he hasn't logged in yet.
Thanks!
There's a couple of ways to interpret your question, so I'll answer both... (I'm speaking from the perspective of using the Java API, but it should be pretty similar on C#.)
1. Can I tell whether the user connect to Bloomberg (i.e. are there network issues / are they are logged in)?
Yes - you can create a new Session, try to start it using .start(). If it fails or returns false, you cannot connect. If it starts, you can call .openService("//blp/apiauth"). Again, if it fails or returns false, you cannot connect.
If you cannot connect, you may or may not be able to determine why you cannot... Nevertheless, I would suggest registering a callback to the BLP API logging framework. In our code, we we-direct these to the logging framework we use throughout our code.
2. The user has created a Session (pre-cursor to a Service) - can I tell if the Session has been started?
Unfortunately - no. There is nothing in the API to allow you to determine the state of the Session. (I suppose you could try starting it, and if it starts it wasn't started, and if it fails, it was started - but that strikes me as an unhelpful or risk appraoch.)

is possible to keep session alive using NSURLConnection doing different requests?

I am using NSRULConnection to make http request on my iphone application. All works just fine.
The problem is after logged in I need to keep the same session to get data from the server.
I read a few posts saying all I need was using the same instance of NSURLConnection and it would use the same session... if that is true, that doesn't make sense to me, cause the NSURLConnection is not mutable and there is no method to change the request since I have to access different pages.
Is there anyway simple way to keep a session using NSURLConnection.
If you are managing sessions using cookies, there is no need to do anything special to achieve session management.The URL loading system automatically sends any stored cookies appropriate for an NSURLRequest. unless the request specifies not to send cookies. So, your sessions should be managed automatically for you.
However, as the Apple's doc says, if someone has set the cookie-acceptance policy to reject all cookies or only accept cookies selectively, you might be in a fix (you can change the cookie acceptance policy yourself too). In such a case, you might resort to URL based session-management; in which you append a session-identifier to the URL as a parameter (You can get this identifier as a part of the successful log-in response), which can be extracted on the server-side. This, however, is considered really bad practice.
Another way, which I have come across more often, is to get a session-identifier as part of the response for a successful log-in and include that identifier in all your subsequent requests as a parameter. Although this would require a major change in the way the server handles the sessions.