sdk/oapiSdk/samples/api/hire/v1/combined_update_job_sample.py

127 lines
4.9 KiB
Python
Raw Permalink Normal View History

2025-08-19 10:20:23 +00:00
# Code generated by Lark OpenAPI.
import lark_oapi as lark
from lark_oapi.api.hire.v1 import *
def main():
# 创建client
client = lark.Client.builder() \
.app_id(lark.APP_ID) \
.app_secret(lark.APP_SECRET) \
.log_level(lark.LogLevel.DEBUG) \
.build()
# 构造请求对象
request: CombinedUpdateJobRequest = CombinedUpdateJobRequest.builder() \
.job_id("6960663240925956660") \
.user_id_type("open_id") \
.department_id_type("open_department_id") \
.job_level_id_type("people_admin_job_level_id") \
.job_family_id_type("people_admin_job_category_id") \
.request_body(CombinedJob.builder()
.id("6960663240925956576")
.experience(1)
.expiry_time(0)
.customized_data_list([])
.min_level_id("6960663240925956547")
.min_salary(1000)
.title("后端研发")
.job_managers(JobManager.builder().build())
.job_process_id("6960663240925956554")
.subject_id("6960663240925956555")
.job_function_id("6960663240925956555")
.department_id("6960663240925956549")
.head_count(100)
.is_never_expired(False)
.max_salary(2000)
.requirement("熟悉后端研发")
.description("后端研发岗位描述")
.highlight_list([])
.job_type_id("6960663240925956551")
.max_level_id("6960663240925956548")
.required_degree(20)
.job_category_id("6960663240925956550")
.address_id_list([])
.job_attribute(1)
.expiry_timestamp("1622484739955")
.target_major_id_list([])
.build()) \
.build()
# 发起请求
response: CombinedUpdateJobResponse = client.hire.v1.job.combined_update(request)
# 处理失败返回
if not response.success():
lark.logger.error(
f"client.hire.v1.job.combined_update failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}")
return
# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))
# 异步方式
async def amain():
# 创建client
client = lark.Client.builder() \
.app_id(lark.APP_ID) \
.app_secret(lark.APP_SECRET) \
.log_level(lark.LogLevel.DEBUG) \
.build()
# 构造请求对象
request: CombinedUpdateJobRequest = CombinedUpdateJobRequest.builder() \
.job_id("6960663240925956660") \
.user_id_type("open_id") \
.department_id_type("open_department_id") \
.job_level_id_type("people_admin_job_level_id") \
.job_family_id_type("people_admin_job_category_id") \
.request_body(CombinedJob.builder()
.id("6960663240925956576")
.experience(1)
.expiry_time(0)
.customized_data_list([])
.min_level_id("6960663240925956547")
.min_salary(1000)
.title("后端研发")
.job_managers(JobManager.builder().build())
.job_process_id("6960663240925956554")
.subject_id("6960663240925956555")
.job_function_id("6960663240925956555")
.department_id("6960663240925956549")
.head_count(100)
.is_never_expired(False)
.max_salary(2000)
.requirement("熟悉后端研发")
.description("后端研发岗位描述")
.highlight_list([])
.job_type_id("6960663240925956551")
.max_level_id("6960663240925956548")
.required_degree(20)
.job_category_id("6960663240925956550")
.address_id_list([])
.job_attribute(1)
.expiry_timestamp("1622484739955")
.target_major_id_list([])
.build()) \
.build()
# 发起请求
response: CombinedUpdateJobResponse = await client.hire.v1.job.acombined_update(request)
# 处理失败返回
if not response.success():
lark.logger.error(
f"client.hire.v1.job.acombined_update failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}")
return
# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))
if __name__ == "__main__":
# asyncio.run(amain()) 异步方式
main()